使用this.$router.push打開新頁面,路由傳參

this.$route.query

# 兩種方式皆可

1
2
3
4
let pushRouter = this.$router.resolve(
`/targetPath?id=${id}&name=${name}&number=${number}`
);
window.open(pushRouter.href, "_blank");
1
2
3
4
5
6
7
8
9
let pushRouter = this.$router.resolve({
path: `/targetPath`,
query: {
id: id,
name: name,
number: number
}
});
window.open(pushRouter.href, "_blank");

# 查詢完整網址

1
window.location.href;

# 查詢路徑

1
this.$route.path;

# 查詢query

1
this.$route.query;

# 會在url中帶引數

路由頁面跳轉,重新整理過後,資料依然存在

1
2
// ex:
http://localhost:8080/targetPath?id=${id}&name=${name}&number=${number}

this.$route.params

1
2
3
4
5
6
7
8
this.$router.resolve({
path: `/targetPath`,
params: {
id: id,
name: name,
number: number
}
});

# 查詢params

1
this.$route.params.id;
# 不會在url中帶引數

路由頁面跳轉,重新整理過後,資料及不存在