javascript - 想要从 Vuejs 中的 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 = 'some url'; 适用于非单页应用程序。
原始答案:Vue.js 重定向到另一个页面
推荐阅读
- python - 如何将熊猫数据框转换为命名元组
- compiler-warnings - 我应该如何初始化一个 BerkeleyDB 键数据对来获取?
- laravel - 查询生成器 - 左连接无法正常工作
- java - @Before 没有为 @Test 实例化我的对象
- javascript - 如何使用 jQuery 平滑地隐藏和显示按钮?
- corda - 结合cordapp jars
- apache-camel - 如何修复文本中缺少 ${:错误 - Apache Camel 2.12 到 2.16.4 升级
- python-3.x - 如何在matplotlib中为图形添加背景图片
- rust - 调用函数时移动所有权会复制“self”结构吗?
- sql - INSERT ALL 错误 ORA-02291 完整性约束,但引用了 PK