vue项目线上发布后,打开新窗口路由会跳到首页(“/) #12250
Unanswered
992076178
asked this question in
Help/Questions
Replies: 3 comments
-
this is my answer, it may be helpful https://stackoverflow.com/a/79302293/17601704 In vue router 4 for vue3 firsttry to find the mounted APP.vue, when you refresh the webpage, the App.vue will be loaded firstly. So make sure you don't mounted mounted() {
this.$router.push("/");
} the correct thing mounted() {
this.loading();
},
methods: {
loading() {
if(document.URL=="http://localhost:9000/" || document.URL=="https://zoujiu.com.cn/"
|| document.URL=="http://zoujiu.com.cn/" || document.URL=="http://localhost:9000/#/"
|| document.URL=="http://zoujiu.com.cn/#/"|| document.URL=="https://zoujiu.com.cn/#/"
) {
this.$router.push({ path: '/'});
}
}
} deploymentI use this history with nginx ssl https const router = createRouter({
// history: createMemoryHistory(),
history: createWebHashHistory(),
// history: createWebHistory(),
routes:constantRoutes,
}) developmentI use this history const router = createRouter({
// history: createMemoryHistory(),
// history: createWebHashHistory(),
history: createWebHistory(),
routes:constantRoutes,
}) this is myown website http://zoujiu.com.cn. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
vue项目在本地运行各个页面路由跳转无问题,但是打包发布之后,在打开新窗口操作时就会偶尔跳转到"/",不是100%出现但是非常影响使用
Beta Was this translation helpful? Give feedback.
All reactions