大致步骤:
- 使用
this.$router.resolve
来获取跳转路径和携带参数等信息; - 使用
window.open()
进行新标签页跳转;
具体:
传参记得用 query,用 params 接收不到:
const routeUrl = this.$router.resolve({
name: "toExam",
query: {
isReview: true,
sid: id
},
});
window.open(routeUrl.href, "_blank");
如果是这种情况:
<h4
style="cursor: pointer;"
onclick="window.location.href='#/detail?id=${accident.id}'">${accident.sname}
</h4>
可以改为:
<h4
style="cursor: pointer;"
onclick="window.open('#/detail?id=${accident.id}','_blank')">${accident.sname}
</h4>
就可以跳转到新标签页了