【发布时间】:2019-10-07 22:06:13
【问题描述】:
我试图更好地理解包含节点组件和其他 js 的 webpacked 包中的范围。
假设我的条目导入了八个要捆绑的文件: // 入口点 导入'./components/file1'; 导入'./components/file2'; ... 导入'./components/file8';
假设在 file1.js 我有:
// file1.js
let bubbles = () => {
console.log('likes cats');
};
// or
function bubbles() {
console.log('likes cats');
}
那么,如果我在 files8 中有这个(最后导入),为什么会引发未定义的错误?如何调用其他导入中声明的函数?
// file8.js
bubbles(); // fails in any file other than file1.js where it's declared.
【问题讨论】:
标签: javascript node.js scope