【发布时间】:2021-11-03 01:44:34
【问题描述】:
有谁知道在语法上是否可以将参数属性应用为父函数引用的局部范围方法。
模块非常大,会增加页面加载时间,不应通过顶级 import() 导入。
import {method1, method2, method3} from "./module.js" //not an option
//Working example.
$('some-id').on('click', () => {
import ("./module.js")
.then( (module) => {
module.method();
module.method2();
module.method3();
// module methods...
});
}
//Something along these lines.
$('some-id').on('click', () => {
import ("./module.js")
.then( ( module ) => {
method();
method2();
method3();
//Apply the module methods to function scope without direct reference to the parameter
//this would save some time and loads of repetition if possible, question is can anything similar be done.
});
}
【问题讨论】:
标签: javascript jquery import parameters lazy-loading