使用 vue.路由器重定向到绝对路径

我可以找到的所有示例都有助于管理应用程序内的路由,如下所示

this.$router.push({name: RouteName})

如果我想通过绝对路径进行重定向怎么办?我尝试

this.$router.push({fullPath: https://google.com})

但它什么都不做


牧羊人nacy
浏览 188回答 1
1回答

慕的地6264312

浏览器专为在应用内进行路由而设计。使用它来重定向到外部站点是没有意义的。您仍然可以像这样使用vue路由器:this.$router.push({ redirect: window.location.href = 'https://google.com' });但是最好使用香草js:window.location.href = 'https://google.com';
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

JavaScript