React 导入 Jquery-Ui 可排序
React import Jquery-Ui sortable
我试过用Jquery-Ui排序。我是这样做的:
import React from 'react';
import $ from 'jquery';
import sortable from 'jquery-ui/ui/widgets/sortable';
class test extends React.Component {
componentDidMount() {
$('.element').sortable();
}
render() {...}
}
效果很好,但我有一个问题:
我收到警告:
编译时带有警告。
'sortable' 已定义但从未使用过
如果我遗漏了可排序的导入,它就不起作用。
我该如何解决?
Sortable 是 JQuery 的插件,因此无需导入为变量:
import sortable from 'jquery-ui/ui/widgets/sortable';
改为
import 'jquery-ui/ui/widgets/sortable';
我试过用Jquery-Ui排序。我是这样做的:
import React from 'react';
import $ from 'jquery';
import sortable from 'jquery-ui/ui/widgets/sortable';
class test extends React.Component {
componentDidMount() {
$('.element').sortable();
}
render() {...}
}
效果很好,但我有一个问题: 我收到警告: 编译时带有警告。 'sortable' 已定义但从未使用过
如果我遗漏了可排序的导入,它就不起作用。 我该如何解决?
Sortable 是 JQuery 的插件,因此无需导入为变量:
import sortable from 'jquery-ui/ui/widgets/sortable';
改为
import 'jquery-ui/ui/widgets/sortable';