es6 动态加载实例的调用函数 class
Call function of a dynamically loaded instance of a es6 class
我正在尝试使用 webpack 动态导入“SampleModuleController”class 并按如下方式调用其成员函数。
sampleModule.js
class SampleModuleController{
getSampleModuleSheet()
{
console.log("getSampleModuleSheet");
}
}
export let sampleModuleController = new SampleModuleController();
在另一个 class 文件中...
async clicked(){
const getView = await import('../../controllers/sampleModule');
console.log("getView--",getView);
getView.getSampleModuleSheet();
}
但它给了我以下日志和错误
async clicked() {
const {sammpleModuleController: getView} = await import ('../../controllers/sampleModule');
console.log("getView--", getView);
getView.getSampleModuleSheet();
}
我正在尝试使用 webpack 动态导入“SampleModuleController”class 并按如下方式调用其成员函数。
sampleModule.js
class SampleModuleController{
getSampleModuleSheet()
{
console.log("getSampleModuleSheet");
}
}
export let sampleModuleController = new SampleModuleController();
在另一个 class 文件中...
async clicked(){
const getView = await import('../../controllers/sampleModule');
console.log("getView--",getView);
getView.getSampleModuleSheet();
}
但它给了我以下日志和错误
async clicked() {
const {sammpleModuleController: getView} = await import ('../../controllers/sampleModule');
console.log("getView--", getView);
getView.getSampleModuleSheet();
}