我有一个包含以下内容的
我希望将这个组件发布为npm包,以便通过“npm install my-component”使用该组件。
当我尝试从编译后的js文件中导入组件进行测试时,会出现“[Vue warn]: Failed to mount component: template or render function not defined”错误。
但是,当我从“.vue”文件中导入组件时,它能正常工作。
index.js
文件:import MyComponent from './components/MyComponent.vue';
module.exports = MyComponent;
我希望将这个组件发布为npm包,以便通过“npm install my-component”使用该组件。
当我尝试从编译后的js文件中导入组件进行测试时,会出现“[Vue warn]: Failed to mount component: template or render function not defined”错误。
但是,当我从“.vue”文件中导入组件时,它能正常工作。
export default MyComponent
代替module.exports = MyComponent;
,这样可以避免使用@mrabbani
。 - Saurabh