在线观看不卡亚洲电影_亚洲妓女99综合网_91青青青亚洲娱乐在线观看_日韩无码高清综合久久

鍍金池/ 問答/HTML/ vue 里面公共方法怎么去實(shí)現(xiàn)跳轉(zhuǎn)路由

vue 里面公共方法怎么去實(shí)現(xiàn)跳轉(zhuǎn)路由

現(xiàn)在將用一個js文件 封裝了axios 想在這里對查詢出來的狀態(tài) 統(tǒng)一做錯誤處理,權(quán)限處理(比如沒權(quán)限就跳轉(zhuǎn)到登錄頁面,修改store里面的狀態(tài)) 這個公共的js文件 我怎么去調(diào)用 this.$route this.$store 這樣的方法

我看別人有的項(xiàng)目是 在公共的方法里 又新建了一個實(shí)例

const vue = new Vue({
    store,
    router
});

通過vue.$store vue.$route 去實(shí)現(xiàn)跳轉(zhuǎn)與更改 這相當(dāng)于是新建了兩個vue對象了 為什么可以這樣做

有沒有其他的辦法

回答
編輯回答
擱淺

main.js

import axios from '@/router/axios'
import router from '@/router/index';
import store from '@/tools/vuex';
axios.init(router,store);

axios.js

import axios from 'axios'
const axiosInstance = axios.create()
export default{
  init(router,store){
    // ....interceptors
  }
}
2017年2月21日 22:11