第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問(wèn)題,去搜搜看,總會(huì)有你想問(wèn)的

vue-router.js里如何使用餓了么組件的彈框等的方法

vue-router.js里如何使用餓了么組件的彈框等的方法

函數(shù)式編程 2019-05-22 22:28:54
methods:{open5(){this.$notify.info({title:'消息',message:'這是一條消息的提示消息'});}}這是餓了么UI的彈框方法,也是放到了單獨(dú)的一個(gè)pop.vue組件importpopfrom'@/components/pop'router.beforeEach((to,from,next)=>{if(to.path==='/login'||to.path==='/'){next()}else{if(Cookies.get('uName')){next()}else{next({path:'/login'})alert('請(qǐng)重新登錄')pop.methods.open5()//就是這里,使用報(bào)錯(cuò)}}})這是router.js的守衛(wèi)我想在重新登錄這使用open5這個(gè)方法,但是報(bào)錯(cuò),this不對(duì)
查看完整描述

2 回答

?
波斯汪

TA貢獻(xiàn)1811條經(jīng)驗(yàn) 獲得超4個(gè)贊

可以參考我的:
importElementUIfrom'element-ui'
import'element-ui/lib/theme-chalk/index.css'
Vue.use(ElementUI)
import{Notification}from'element-ui'
//鉤子函數(shù)路由判斷
router.beforeEach((to,from,next)=>{
if(to.meta.requireAuth){
if(localStorage.token){
//console.log("已有個(gè)人信息!");
next();
}else{
Notification.error({message:'請(qǐng)先登錄!',duration:1000,position:'bottom-right',showClose:false})
next({
path:'/login',
//跳轉(zhuǎn)到登錄頁(yè)
})
}
}
else{
next();
}
})
                            
查看完整回答
反對(duì) 回復(fù) 2019-05-22
  • 2 回答
  • 0 關(guān)注
  • 431 瀏覽
慕課專(zhuān)欄
更多

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)