我在同一个域中有一个外部网站和 vue 应用程序。我想以编程方式将用户从 vue 应用程序重定向到外部网站,并重新加载整个页面。
示例
http://example.com --> vue + vue-router 应用
http://example.com/external-site --> 外部网站
最佳答案
在 Vue 2.x 中,您可以通过添加这样的路由来创建将转到外部 URL 的路由:
{
path: "/Stackoverflow",
component: Stackoverflow,
beforeEnter(to, from, next) {
window.location.href = "https://stackoverflow.com";
}
}
激活使用:
this.$router.push({ path: '/Stackoverflow' });
关于vue.js - 以编程方式重定向到 vue-router 应用程序外部但在同一域中的 URL?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58403551/