【发布时间】:2019-10-22 14:05:06
【问题描述】:
我正在尝试解决this code 的问题:
import globalComponents from './global-components';
// ...
globalComponents.forEach((component) => {
// eslint-disable-next-line no-underscore-dangle
Vue.component(component.__file.split('/').pop().split('.')[0], component);
});
globalComponents 是一个包含 index.js 的目录,它导入和重新导出两个 Vue.js 组件文件。我不知道你能做到这一点,但我想这是一种类似 python 模块层次结构的方法。
无论如何,这段代码在调试模式下运行良好,但在为发布而构建时,应用程序无法加载,因为组件对象没有 __file 属性。这段代码在做什么?如何让它在生产版本中工作?
【问题讨论】:
标签: javascript vue.js webpack module node-modules