在vue中使用vue-router 实现在新窗口打开页面的功能

130 阅读1分钟

vue2实现

const { href } = this.$router.resolve({
  name: `print_schedule`,
  params: {
    id
  }
});
window.open(href, "_blank");

vue3实现

const router = useRouter();
const { href } = router.resolve({
  path: '/pc/articleDetail',
  query: {
    article_id: utils.encryptCode({ article_id })
  }
});
window.open(href, "_blank");