我试图将jquery.gridster包装为react组件,但得到了一个错误。
‘未捕获的TypeError:(0,_jquery2.default)(...).gridster不是函数’
import $ from 'jquery';
componentDidMount() {
var gridster = $(ReactDOM.findDOMNode(this)).gridster({
widget_margins: [5, 5],
widget_base_dimensions: [150, 150],
resize: {
enabled: true
}
}).data('gridster');
}我已经向index.html添加了脚本标记
<script type="text/javascript" src="assets/jquery.js"></script>
<script type="text/javascript" src="assets/jquery.gridster.js" charster="utf-8"></script>我不确定这是不是正确的方式,不确定如何导入gridster.Has有人尝试过吗?
发布于 2016-04-07 16:08:52
我觉得没问题
import $ from 'jquery'
import gridster from 'gridster/dist/jquery.gridster'在我的webpack配置中
plugins: [
new webpack.ProvidePlugin({
$: "jquery",
jQuery: "jquery"
})
]https://stackoverflow.com/questions/35322607
复制相似问题