require.js, when you output window in the console, you can see that there are Vue instances, but the output window.Vue shows undifind
. I mainly want to call vux"s loading plug-in through the vue instance, but I can"t get this instance to ask for help
import axios from "axios"
import { LoadingPlugin } from "vux"
import Vue from "vue"
Vue.use(LoadingPlugin)
console.logwindow
console.log(window.Vue)
function fetch(config) {
return new Promise((resolve, reject) => {
const instance = axios.create({
transformRequest: [function (data) {
return data
}]
});
instance.interceptors.request.use(config => {
config.headers["Content-Type"]= "application/x-www-form-urlencoded";
return config
}, error => {
Promise.reject(error)
})
instance(config).then(res => {
// console.log(res);
resolve(res);
//
}).catch(err => {
console.log(err);
reject(err);
})
});
}
function myaxios(url,type,data,msgtype) {
return fetch({
url: url,
method: type,
data: data,
headers: {
}
})
}
export default myaxios
in main.js
import myaxios from "./utils/require"
Vue.prototype.$axios = myaxios