方法一:
router/index.js
{ path: '/src/views/activitiesDetails', name: activitiesDetails, component: activitiesDetails, meta: { title: '精选活动' } },
index.vue
detalis(id){ this.$router.push({ path: '/src/views/activitiesDetails', query: { id: id } }) },
获取id
console.log(this.$route.query.id)
方法二:
window.location.href ="/src/views/activitiesDetails?id=" + id
获取id
console.log(this.$route.query.id)
方法三:
{ path: '/src/views/activitiesDetails/:id', name: activitiesDetails, component: activitiesDetails, meta: { title: '精选活动' } },
index.vue
detalis(id){ this.$router.push(`/src/views/activitiesDetails/${id}`) ; },
获取id
mounted() { console.log(this.$route.params.id); }
写在最后:
每次整理一点点,每天进步一点点,✌️