[英]How to Create NPM packages from a .vue file
我有一个index.js
文件:
import MyComponent from './components/MyComponent.vue';
module.exports = MyComponent;
我想将它作为npm package
发布,以便我可以通过npm install my-component
使用这个npm install my-component
当我尝试通过从编译的js文件导入组件进行测试得到[Vue warn]: Failed to mount component: template or render function not defined
但是当我从.vue
文件导入时工作正常。
您只需要在package.json
的目录和main字段中添加package.json
即可为组件添加主入口点。
你可以看看这个简单的npm组件: vue-just-another-dropdown ,它会给你更多的想法。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.