使用代码拆分后,我无法找到如何在我的 React 应用程序中导入类。
之前(它有效!):
import React, {PureComponent} from 'react';
import Tus from './components/test';
class Shopper extends PureComponent {
constructor (props) {
super(props); }
uploadModal () {
/* some function code... */
.use(Tus, {
endpoint: 'http://192.168.22.124:3000/upload/'
})
/* more codes... */
}
使用代码拆分后(不起作用):
import React, {PureComponent} from 'react';
class Shopper extends PureComponent {
constructor (props) {
super(props); }
uploadModal () {
/* some function code... */
.use(import('./components/test').then(Tus => Tus, {
endpoint: 'http://192.168.22.124:3000/upload/'
})
/* more codes... */
}
使用代码拆分后出现此错误
TypeError:需要一个插件类,但得到了对象。请验证插件是否已导入且拼写正确。
当我控制台.log
import('./component/test').then(Tus => console.log(Tus))
我明白了:
ƒ Tus(uppy, opts) {
_classCallCheck(this, Tus);
var _this = _possibleConstructorReturn(this, _Plugin.call(this, uppy, opts));
_this.type = 'uploader';
_this.id = 'Tus';
_this.titl…