this.$router.push添加blank
时间: 2024-05-08 11:13:20 浏览: 161
this.$router.push可以用于在Vue.js中进行页面跳转,而添加blank可以在跳转时打开新窗口。具体实现方式为:
this.$router.push({ path: '/your-path', query: { key: value }, target: '_blank' });
其中target: '_blank'表示在新窗口中打开跳转的页面。需要注意的是,该方法仅在使用Vue.js的情况下才能使用。如果你想在普通HTML页面中打开新窗口,可以使用<a>标签,并添加target="_blank"属性。
相关问题
this.$router.push报错
this.$router.push报错是因为最新版的vue-router引入了promise,当使用this.$router.push()时会返回一个promise对象。如果没有捕获这个promise对象,就会出现Uncaught (in promise)错误。解决这个问题的方法有两种。第一种方法是直接在push()后调用一个catch方法,例如this.$router.push(this.path).catch(err=>err)。第二种方法是重写原型中的push方法,具体的代码可以参考这个链接:https://blog.csdn.net/haidong55/article/details/100939076。<span class="em">1</span><span class="em">2</span><span class="em">3</span>
#### 引用[.reference_title]
- *1* *2* [$route.push()多次点击跳转报错问题](https://blog.csdn.net/qq_52693197/article/details/124692850)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"]
- *3* [调用$router.push()时报出Uncaught (in promise)错误](https://blog.csdn.net/weixin_42761614/article/details/113346398)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"]
[ .reference_list ]
this.$router.push path
this.$router.push(path)是Vue Router中的一个方法,用于导航到指定的路径。该方法会将当前路径添加到路由历史记录中,并加载新的路径页面。通过传入一个路径参数,可以实现跳转到指定的页面。例如,可以使用以下方式实现跳转到path路径所对应的页面:
this.$router.push(path)<span class="em">1</span><span class="em">2</span><span class="em">3</span>
#### 引用[.reference_title]
- *1* [Vue中 this.$router.push 传参 及 参数接收](https://blog.csdn.net/chenxi_li/article/details/108365779)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT3_1"}}] [.reference_item style="max-width: 50%"]
- *2* *3* [Vue中的路由导航](https://blog.csdn.net/qq_44858608/article/details/124070219)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT3_1"}}] [.reference_item style="max-width: 50%"]
[ .reference_list ]
阅读全文