In vue, how to make the list click events in the list looped out by v-for jump to different pages

  <ul>
    <li v-for="(item,key) in list" :key="key">
      <span @click="$router.push()">{{item.name}}</span>
    </li>
  </ul>
  
  list: [{
    name: ""
  }, {
    name: ""
  }, {
    name: ""
  }, {
    name: ""
  }]
  
  
  
  
Mar.02,2021

you can add route fields to your list array, and dynamically get their respective hop routes when you click


give you an official document link: https://router.vuejs.org/zh-c.


<ul>
    <li v-for="(item,key) in list" :key="key">
      <router-link :to=""></router-link>
    </li>
  </ul>

just traverse the corresponding route into the: to of router-link.

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1ea061b-1ac8.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1ea061b-1ac8.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?