---- How vue-router open the page in a new window ----

1. <router-link> tag to achieve new window:

The official document said v-link instruction is replaced by <router-link> component directive, and <router-link> does not support target = "_ blank" attribute, if you need to open a new window <a> tag must be used, but in fact vue2 version <router-link> support target = "_ blank" attribute (tag = "a"), as follows:

<router-link target="_blank" :to="{path:'/home',query:{id:'1'}}">新页面打开home页</router-link>

2, the navigation programming:

Sometimes the need to implement a page or jump function in the click event, you can router method by way of example, to achieve by writing code. We used a $ router.push and $ router.go But after vue2.0, in this way do not support the new window opens the property, and this time you need to use this $ router.resolve, as follows:

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

Of course, you can use the query, you can also use params, For details, see: https://www.jianshu.com/p/45ee7a6bdc0c 

 
 

Guess you like

Origin www.cnblogs.com/zjy850984598/p/11460978.html