1、在列表页传值this.$router.push()

  1. <div @click="handleClick(data.id)"></div>
  2. export default {
  3. name:"Item",
  4. props:{
  5. data:{
  6. type:Object,
  7. required:true
  8. }
  9. },
  10. methods:{
  11. handleClick(id){
  12. console.log(id)
  13. this.$router.push(`/detail?id=${id}`)
  14. }
  15. }
  16. };

2、 在详情页接收值this.$route.query

  1. export default {
  2. name:"Detail",
  3. computed:{
  4. id(){
  5. return this.$route.query.id
  6. }
  7. }
  8. };

3、 在详情页跳转回列表页

  1. methods:{
  2. toggle(){
  3. this.$router.back();
  4. }
  5. }