1. 程式人生 > >記一次 vue 打包的問題

記一次 vue 打包的問題

事件的經過:

一開始採取了 vue 、axaio、vue-router 等不打包在一起的方式,,後來發現總專案並不大,就想把它們都打包在一起算了,,,然後問題出來了

1、連線進專案的 ,mint 的一些元件找不到

import {Toast,Indicator,Loadmore ,Picker} from 'mint-ui';

直接呼叫  toast 和 Indicator 的時候為  undefined?????

在外接 vue 的時候卻可以用,,打包在一起的時候就找不到了??? 原因不是很明白(找到答案再更新)

解決:

 把他們接入 vue

Vue.prototype.$indicator = Indicator;
Vue.prototype.$toast = Toast;

2、元件名稱只能包含字母數字字元和連字元,並且必須以字母開頭。

在外接 vue 的時候卻可以用,,打包在一起的時候就報這種錯。。見鬼了

[Vue warn]: Invalid component name: "我釋出的". Component names can only contain alphanumeric characters and the hyphen, and must start with a letter.

3、自己寫的彈框元件模板裡的方法沒在  methods  裡面定義,我在 js 檔案裡定義了,然後報錯

Property or method "subStateClick" is not defined on the instance but referenced during render. Make sure that this property is reactive, either in the data option, or for class-based components, by initializing the property. See




解決:

在 methods 裡面先定義一個方法,然後通過 js 改寫

4、元件裡傳進去的引數又在data 裡面定義過,然後報錯

The data property "show" is already declared as a prop. Use prop default value instead.

解決:把元件裡重複定義的去掉就好了