vue-router function to open the page in a new window

Problem: suddenly received a need to open a new page in the function vue project

By watching vue-router, can also achieve this function, as follows:

1. Open a new window is achieved by <router-link> tag

<router-link
        target="_blank"
        :to="{ path:'/details', query: { id:'1' } }">详情</router-link>

2. navigate through Function

methods: {
  goDetails (id) {
      const { href } = this.$router.resolve({
        path: `/details`,
        params: {
          id: id
        }
      });
      window.open(href, "_blank");
  } 
}

Guess you like

Origin www.cnblogs.com/zaijin-yang/p/11971210.html