想从AXIOS GET api调用重定向到URL



获得AXIOS api响应后,我需要在新选项卡中重定向到url。

目前,我使用window.open("url")在api调用中实现这一点,如下所示。

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 = ' someurl ';

原始答案:Vue.js重定向到另一个页面

简单解决方案

我在我的项目中使用这个,我目前正在工作router.push美元。("/this.urlimage";

最新更新