vue 传参动态
方法一:
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); }
写在最后:
每次整理一点点,每天进步一点点,✌️
本文来自博客园,作者:_小狐狸,转载请注明原文链接:https://www.cnblogs.com/zwh520/p/13749558.html