我希望我的浏览器化构建需要[医]欧巴维氏红字器 (npm包)的代码。但我得到了一个不可预测的错误。
这是react元素的代码
React = require('react')
ReactBootstrap = require('react-bootstrap')
Input = ReactBootstrap.Input
Button = ReactBootstrap.Button
require('bower-redactor/redactor/redactor-plugins/table.js')
require('bower-redactor/redactor/redactor.js')
require('bower-redactor/redactor/langs/ru.js')
module.exports = React.createClass
componentDidMount: ->
jQuery('textarea.redactor').redactor
lang: 'ru'
plugins: ['table']
render: ->
<form>
...
<Input type='textarea' ref='content' className='redactor' defaultValue={@props.content} />
...
</form>在我require('bower-redactor/redactor/redactor-plugins/table.js')并将plugins: ['table']添加到代码之前,一切都进行得很顺利。我收到一个错误:ReferenceError: RedactorPlugins is not defined at redactor.js#L1430
但是它们是在table.js中定义的,这在redactor.js之前是必需的,为什么我会得到这个错误。我如何避免它并开始成功地使用redactor.js?
我尝试过很多东西:褐化-垫片包装、制作global.RedactorPlugins = {}等等,但都没有成功。
发布于 2015-09-16 16:33:43
您需要将代码包含在包中。它将是全球性的,所以你只需参考它。要求是行不通的。喝了一口,它就会像这样;
var source = {
libjs: ['bower-redactor/redactor/redactor-plugins/table.js', 'bower-redactor/redactor/redactor.js', 'bower-redactor/redactor/langs/ru.js']
};
gulp.task('libjs', function () {
gulp.src(source.libjs)
.pipe(concat('lib.min.js'))
.pipe(gulp.dest('./ui-dist'))
});https://stackoverflow.com/questions/32608050
复制相似问题