首先在B(被關聯的項目)項目根目錄建立一個inde.js文件。
B項目
運行命令:npm link
以B文件的components下的bars.vue文件爲例子:
index.js內容爲:
important bars form "./src/components/bars.vue"
B項目中package.json文件中在json對象的頂部加:
加"main":"index.js";
A項目
運行命令:npm link B
在header.vue文件中引入:
important {bars} form "B"
components:{bars:bars}
然後再template中直接,寫入<bars></bars>