我尝试使用Jquery可排序。我是这样做的:
import React from 'react';
import $ from 'jquery';
import sortable from 'jquery-ui/ui/widgets/sortable';
class test extends React.Component {
componentDidMount() {
$('.element').sortable();
}
render() {...}
}
这很好,但我有一个问题:我得到警告:用警告编译。定义了“排序”,但从未使用过。
如果我省略了可排序的导入,它就不工作了。我怎么才能解决呢?
发布于 2019-12-28 14:36:52
Sortable是JQuery的插件,因此不需要作为变量导入:
import sortable from 'jquery-ui/ui/widgets/sortable';
更改为
import 'jquery-ui/ui/widgets/sortable';
https://stackoverflow.com/questions/59511715
复制相似问题