3
我有一個index.js
文件與創建NPM包:如何從.vue文件
import MyComponent from './components/MyComponent.vue';
module.exports = MyComponent;
我要發佈這爲npm package
,使我可以通過npm install my-component
當我嘗試使用這個組件通過從編譯後的js文件中導入組件進行測試得到[Vue warn]: Failed to mount component: template or render function not defined
但是工作正常時我從.vue
文件導入。
當我從編譯的js文件導入得到「[Vue警告]:無法裝入組件:模板或渲染功能未定義」。 – mrabbani
你可以發佈這個組件的整個代碼,你在哪裏使用它,可能會有一些其他的錯誤。 – Saurabh
@mrabbani而不是'module.exports = MyComponent;'嘗試'導出默認的MyComponent' – Saurabh