Home  >  Article  >  Web Front-end  >  How to implement page jump in vue

How to implement page jump in vue

藏色散人
藏色散人Original
2021-09-11 11:16:0635724browse

vue实现页面跳转的方法:1、通过006d1f5546c9ee58ed9ac9eef4f3fa5f标签实现新窗口打开;2、通过在单击事件或者在函数中实现页面跳转即可。

How to implement page jump in vue

本文操作环境:windows7系统、vue2.9.6版,DELL G3电脑。

vue如何实现页面跳转?在vue项目中如何实现跳转到一个新页面

记录一下在vue项目中如何实现跳转到一个新页面(一个比较简单又比较基础的问题了),有两个方法:

1、006d1f5546c9ee58ed9ac9eef4f3fa5f标签实现新窗口打开

官方文档中说 v-link 指令被 b988a8fd72e5e0e42afffd18f951b277 组件指令替代,且 b988a8fd72e5e0e42afffd18f951b277 不支持 target="_blank" 属性,如果需要打开一个新窗口必须要用3499910bf9dac5ae3c52d5ede7383485标签,但事实上vue2版本的 b988a8fd72e5e0e42afffd18f951b277 是支持 target="_blank" 属性的(tag="a"),如下:

 

新页面打开home页

 

2、编程式导航

有些时候需要在单击事件或者在函数中实现页面跳转,那么可以借助router的示例方法,通过编写代码实现。

我们常用的是 $router.push 和 $router.go 但是vue2.0以后,这种方式就不支持新窗口打开的属性了,这个时候就需要使用this.$router.resolve,如下:

seeShare(){
   let routeUrl = this.$router.resolve({
     path: "/share",
     query: {id:96}
   });
     //let routeUrl = this.$router.resolve(`/share/${96}`)
   window.open(routeUrl.href, '_blank');
}

相关推荐:《vue.js教程

The above is the detailed content of How to implement page jump in vue. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn