可以在按钮的点击事件处理函数中使用 router.push
方法来跳转页面,在跳转时将数据的 id 作为参数传递。然后在跳转到的页面中,可以使用路由对象的 $route.params
属性来获取这个 id。
示例代码如下:
<template>
<div>
<button @click="goToPage(item.id)">跳转</button>
</div>
</template>
<script>
export default {
methods: {
goToPage(id) {
this.$router.push({ name: 'page', params: { id } })
}
}
}
</script>