要实现点击按钮后跳转到指定页面并携带查询参数(例如id=2
),你可以在Vue组件的方法中使用this.$router.push
来进行编程式导航。以下是一个示例代码:
methods: {
gameUrl(id) {
this.$router.push({ path: '/game', query: { id: id } });
}
}
石家庄栗信科技有限公司前端外包
要实现点击按钮后跳转到指定页面并携带查询参数(例如id=2
),你可以在Vue组件的方法中使用this.$router.push
来进行编程式导航。以下是一个示例代码:
methods: {
gameUrl(id) {
this.$router.push({ path: '/game', query: { id: id } });
}
}