在App.vue中写
created() {
// console.log(this.$route.path, this.$route);
if (this.$router.path !== "/home") this.$router.replace(""); //刷新回到首页
//replace中换成自己的首页路径,我只有/所以里边是空
},
在App.vue组件的created生命周期钩子中,检查当前路由如果不是/home,则使用$router.replace方法将页面重定向到空字符串(代表首页)。这确保了应用启动或刷新后始终显示首页。
在App.vue中写
created() {
// console.log(this.$route.path, this.$route);
if (this.$router.path !== "/home") this.$router.replace(""); //刷新回到首页
//replace中换成自己的首页路径,我只有/所以里边是空
},
3304
1万+

被折叠的 条评论
为什么被折叠?
