vue跳转页面,切换路由
super
2023-03-12 11:41
2042
1)
location.href = "/Home";
2)
常规:
<router-link to="Home">首页</router-link>
进阶:
<router-link :to="Home">首页</router-link>
data() {
return {
Home: ''
}
},
created() {
let token = localStorage.getItem('token');
if (token) {
this.Home = 'Home';
} else {
this.Home = 'Login';
}
},
3)
this.$router.push({ path:'/Home' })
拓展:
1)返回上一页
this.$router.go(-1)
0 条讨论