1.准备好两个vue文件
panda.vue
travel.vue
import travel from '@/components/travel'
- 1
{path: '/travel/:id',name: '测试页面',component: travel}
这是一个点击事件
gettravel(id) {this.$router.push({path: '/travel/' + id,})}},
- 1
- 2
- 3
- 4
- 5
- 6
- 7
这里触发事件,并且传递参数
<span @click="gettravel(item.spotsid)"><h1>点击tiaoz</h1></span>
- 1
- 2
- 3
- 4
<div>{{this.$route.params.id}}</div>