vue組件內(nèi)數(shù)據(jù)變化,怎樣觸發(fā)/調(diào)用函數(shù)
1 回答

呼如林
TA貢獻(xiàn)1798條經(jīng)驗 獲得超3個贊
port {getReferPage} from '../../vuex/getters.js'
export default {
vuex: {
getters: {
referPage: getReferPage,
loginName: state => state.loginName // 用戶名。同時用來判斷是否已經(jīng)登錄
},
actions: {
logout: ({dispatch}) => {
dispatch('SIGN_OUT')
}
}
},
methods: {
// 這里!希望被調(diào)用的函數(shù),當(dāng)用戶登錄后loginName會改變,希望跳轉(zhuǎn)到其他頁面
goIndex () {
if (this.loginName) {
if (this.referPage === window.location.href) {
this.$route.router.go('index')
} else {
window.history.go(-1)
}
}
}
}
- 1 回答
- 0 關(guān)注
- 1428 瀏覽
添加回答
舉報
0/150
提交
取消