【发布时间】:2020-05-01 00:10:41
【问题描述】:
我正在将我的 doIt 函数移动到另一个单独的文件,因为它变得如此之大。
这样做后,我的self.kwindow 在新文件./doIt.js 中变为未定义。
我尝试将其作为参数传递,i.e. 下面但没有。这是怎么做到的?
./big.js
import { doIt } from './doIt.js';
// lots of other JavaScript functions
self.kwindow = initWindow();
setTimeout(() => {
doIt (self.kwindow); <-- recent attempt as param
}, 90);
// previously doIt function was here self.kwindow worked in this scope
./doIt.js (现在在新的单独文件中)
function doIt () {
// lots of stuff, many references to self.kwindow
// self.kwindow no longer recognized in this scope
}
export {
doIt,
};
【问题讨论】:
标签: javascript ecmascript-6 import kendo-ui export