Vue writes a v-for loop on the li tag, writes a @ click event, and clicks and pops up an alert

if a total of 10 li, are looped out, how to write

if only the click events of the first four li take effect.
Mar.15,2021

I think the event entrusts you to tie the event to the ul, click to determine whether it is the first four li


Click on the event to pass a parameter index, determines whether it is alert


based on the parameters.

you can do this:

<ul>
    <li v-for="(item,index) in data" @click="index>3?getData():''"></li>
</ul>

can also do this:

<ul>
    <li v-for="(item,index) in data" @click="getData(index)"></li>
</ul>

getData(index){
    if(index>3}{
        return false;
    }
}
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-1b9fc1f-37856.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-1b9fc1f-37856.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?