1.在package.json中引入第三方组件之后,还需要在main.js中import 对应的组件,然后调用vue.use(),按需引用使用Vue.component(Table.name, Table);
例如:
import Vue from 'vue'
import App from './App.vue'
import iView from 'iview';
import 'iview/dist/styles/iview.css';
import { Table, TableColumn, Input, Autocomplete, DatePicker } from 'element-ui';
import 'element-ui/lib/theme-chalk/index.css'
import './assets/icons/iconfont.js'
import './assets/icons/icon.css'
import './styles/common.less';
Vue.use(iView);
Vue.component(Table.name, Table);
Vue.component(TableColumn.name, TableColumn);
Vue.component(Input.name, Input);
Vue.component(Autocomplete.name, Autocomplete);
Vue.component(DatePicker.name, DatePicker);
new Vue({
el: '#app',
render: h => h(App)
})
2.在config.js中设置引入规则
2.如果用到axios 需要自己创建一个,避免使用通用的axios 请求 被截取,同时创建的axios不应该拦截其他的请求。
3.如果组件中使用的第三方组件(如element)的版本跟引用的程序中的版本不一致,有可能会出错。
4.组件和使用组件的工程都全局引用了iview,引入组件的时候可能会报错
DOMException: Failed to execute 'insertBefore' on 'Node': The node before which the new node is to be inserted is not a child of this node.
at Object.insertBefore (http://10.2.6.73:9797/static/lib/vue.min.js:6:37985)
at http://10.2.6.73:9797/static/lib/vue.min.js:6:55430
at k (http://10.2.6.73:9797/static/lib/vue.min.js:6:55551)
at o.patch (http://10.2.6.73:9797/static/lib/vue.min.js:6:56693)
at o._update (http://10.2.6.73:9797/static/lib/vue.min.js:6:31666)
at o.i (http://10.2.6.73:9797/static/lib/vue.min.js:6:63773)
at St.get (http://10.2.6.73:9797/static/lib/vue.min.js:6:16005)
at St.run (http://10.2.6.73:9797/static/lib/vue.min.js:6:16889)
at At (http://10.2.6.73:9797/static/lib/vue.min.js:6:15026)
at Array.(http://10.2.6.73:9797/static/lib/vue.min.js:6:11498)