大家好 本人是剛學Vue不久的新手
有寫好幾個vue Component,目前想要輸出到npm給其他專案使用
如果只輸出一個的Component index.js 可以成功給其他專案使用
1.但是如果是輸出多個Component的index.js要怎麼寫?
嘗試了好幾天 找不到可以用的寫法
2.其他專案怎麼套用原本Component原有的CSS?
index.js(嘗試過失敗的寫法)
import Env from './views/Env.vue';
import Hello from './views/HelloWorld.vue';
const Components = [
Env, Hello
]
const install = function (Vue, opts = {}) {
Components.forEach(component => {
Vue.component(component.name, component)
})
}
export default {
install
}
package.json
{
"name": "test",
"private": false,
"main": "./dist/base.common.js",
"files": [
"dist/*",
"src/*",
"public/*",
"*.json",
"*.js"
],
"scripts": {
"serve": "vue-cli-service serve",
"build": "vue-cli-service build",
"lint": "vue-cli-service lint",
"build_lib": "vue-cli-service build --target lib --name base './src/index.js'",
"build_wc": "vue-cli-service build --target wc --name base './src/views/*.vue'"
},
...
請求各位Vue高手幫忙指點迷津 謝謝!!