[英]Want to Redirect to URL from AXIOS GET api call in Vuejs
在获得 AXIOS api 响应后,我需要在新选项卡中重定向到 url。
目前我正在使用 api 调用中的window.open("url")
来实现这一点,如下所示。
viewimage(image) {
Nova.request().get(`/showimage/`+image,)
.then(response => {
this.urlimage = response.request.responseURL;
window.open(this.urlimage,'_blank');
});
},
但我想确认在生产环境中在 axios 中使用 window.open("url") 的正确过程是否正确,因为我面临所有浏览器都被阻止的弹出窗口。
如果有任何其他替代方式来实现这一目标? 请从你身边引导我。
谢谢,
如果你使用 vue-router,你应该使用 router.push("yourroutename")。
否则, window.location.href = 'some url'; 适用于非单页应用程序。
原答案: Vue.js 重定向到另一个页面
简单的解决方案
我在我的项目中使用它 我目前正在处理 this.$router.push("/this.urlimage");
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.