Vue插件使用
通过全局方法 Vue.use(plugin)
使用插件
import Vue from 'vue';
import VueRouter from 'vue-router';
Vue.use(VueRouter);
axios在Vue中的使用
axios通过Vue.use无法实现全局插件的挂载
import axios from 'axios';
Vue.use(axios);// TypeError
axios需要挂载在Vue.prototype上,就可以实现全局变量的挂载了
import axios from 'axios';
Vue.prototype.$axios = axios;
// 在Vue实例中可以通过this.$axios进行调用
this.$axios(url,options);