router.beforeResolve根据不同页面定义不同$http
Vue.prototype.$http = axios;Vue.config.productionTip = false;Vue.prototype.$event = new Vue();/* eslint-disable no-new */var init = function() {new Vue({el: "#app",router,stor...
·
Vue.prototype.$http = axios;
Vue.config.productionTip = false;
Vue.prototype.$event = new Vue();
/* eslint-disable no-new */
var init = function() {
new Vue({
el: "#app",
router,
store,
template: "<App/>",
render: h => h(App)
});
};
//这里根据单页面name的指向不同,去访问的接口域名也不同
router.beforeResolve((to, from, next) => {
let url;
if (
to.matched[0].name == "broker-shop" ||
to.matched[0].name == "information"
) {
url = "https://ddd.zhaoshang800.com";
} else if (to.matched[0].name == "brokerage-list") {
url = "https://aaa.zhaoshang800.com";
} else if (to.matched[0].name == "sellhot") {
url = "https://bbb.zhaoshang800.com";
} else if (to.matched[0].name == "enterprise-index") {
url = "http://ccc.zhaoshang800.com";
} else {
url = "https://" + location.host;
}
Vue.prototype.$http.defaults.baseURL = url;
next();
});
更多推荐
已为社区贡献4条内容
所有评论(0)