总会出现引用不当的问题,我们应该如何引用vue中的插件呢?
下载好插件之后再json文件中会出现插件的依赖
问题来了,下载好的插件我们该如何在项目中引用呢?
在main.js文件中
// The Vue build version to load with the `import` command // (runtime-only or standalone) has been set in webpack.base.conf with an alias. import Vue from "vue"; import App from "./App"; import router from "./router"; import store from "./store/index"; import ElementUI from "element-ui"; import VCharts from "v-charts"; import axios from "axios"; import "element-ui/lib/theme-chalk/index.css"; import "./assets/css/main.css"; Vue.config.productionTip = false; Vue.use(ElementUI); Vue.prototype.$axios = axios; Vue.use(VCharts); /* eslint-disable no-new */ new Vue({ el: "#app", render: h => h(App), router, store, components: { App }, template: "<App/>" }); |
1,一般引用:import router from "./router";
2,全局引用:Vue.use(ElementUI);