網(wǎng)站首頁 編程語言 正文
從home.vue組件跳轉(zhuǎn)到news.vue組件調(diào)用beforeRouteEnter,離開news.vue組件調(diào)用beforeRouteLeave
<template>
<ul>
<li>news001 <input type="text"></li>
<li>news002 <input type="text"></li>
<li>news003 <input type="text"></li>
</ul>
</template>
<script>
export default {
name:'News',
data() {
return {
}
},
//進入該組件進行攔截
beforeRouteEnter(to,from,next){
if(to.meta.isAuth){
if(localStorage.getItem("username") === "yaomm"){
next()
}else{
next("/login")
}
}else{
next()
}
},
//離開news頁面時執(zhí)行
beforeRouteLeave(to, from, next){
console.log("守衛(wèi)完成",to)
//如果沒有next()無法離開news頁面
next()
}
}
</script>
原文鏈接:https://blog.csdn.net/qiuyushuofeng/article/details/124846813
相關(guān)推薦
- 2022-04-25 Pandas?時間序列分析中的resample函數(shù)_python
- 2022-11-25 jar包在linux服務(wù)器已經(jīng)運行好但是訪問不到地址的問題及解決方法_Linux
- 2022-07-06 C++單例模式為何要實例化一個對象不全部使用static_C 語言
- 2022-03-15 request doesn‘t contain a multipart/form-data or m
- 2023-04-06 Python中有哪些關(guān)鍵字及關(guān)鍵字的用法_python
- 2022-10-25 laravel-admin 安裝報錯 1071 Specified key was too long
- 2022-03-28 IPython?8.0?Python?命令行交互工具_python
- 2022-05-24 Windows環(huán)境bat腳本獲取文件的創(chuàng)建時間_DOS/BAT
- 最近更新
-
- window11 系統(tǒng)安裝 yarn
- 超詳細win安裝深度學(xué)習(xí)環(huán)境2025年最新版(
- Linux 中運行的top命令 怎么退出?
- MySQL 中decimal 的用法? 存儲小
- get 、set 、toString 方法的使
- @Resource和 @Autowired注解
- Java基礎(chǔ)操作-- 運算符,流程控制 Flo
- 1. Int 和Integer 的區(qū)別,Jav
- spring @retryable不生效的一種
- Spring Security之認證信息的處理
- Spring Security之認證過濾器
- Spring Security概述快速入門
- Spring Security之配置體系
- 【SpringBoot】SpringCache
- Spring Security之基于方法配置權(quán)
- redisson分布式鎖中waittime的設(shè)
- maven:解決release錯誤:Artif
- restTemplate使用總結(jié)
- Spring Security之安全異常處理
- MybatisPlus優(yōu)雅實現(xiàn)加密?
- Spring ioc容器與Bean的生命周期。
- 【探索SpringCloud】服務(wù)發(fā)現(xiàn)-Nac
- Spring Security之基于HttpR
- Redis 底層數(shù)據(jù)結(jié)構(gòu)-簡單動態(tài)字符串(SD
- arthas操作spring被代理目標(biāo)對象命令
- Spring中的單例模式應(yīng)用詳解
- 聊聊消息隊列,發(fā)送消息的4種方式
- bootspring第三方資源配置管理
- GIT同步修改后的遠程分支