【VUE- 跳转打开另一个页面】

第一种写法

<button @click="handleClick">打开另一个页面</button>
handleClick(value) {
  const { row } = value
  const query = {
    cluesId: row.infoId
  }
  const router = this.$router.resolve({ path: '/create-clues', query })
  window.open(router.href, '_blank')
},

$router.resolve:

我们使用this.$router.resolve方法来解析路由地址,将path属性设置为/about,query属性设置为{id: 1},返回一个Promise对象。在Promise对象的then方法中,我们可以获取到路由信息,例如路由的路径、查询参数等。

总之,this.$router.resolve是Vue Router提供的一个API,用于解析路由地址,返回一个包含路由信息的Promise对象。与其他路由跳转方式相比,它不会触发路由跳转,而是用于获取路由信息。

如果需要打开另一个页面,可以使用window.open方法或者location.href属性来实现。

第二种写法

<template>
  <div>
    <button @click="handleClick">打开另一个页面</button>
  </div>
</template>

<script>
export default {
  methods: {
    handleClick() {
      const resolved = this.$router.resolve({ path: '/about', query: { id: 1 } });
      resolved.then((route) => {
        window.open(route.href, '_blank');
      });
    }
  }
}
</script>