Vue renders only the first piece of data in the array

how can I take only the first piece of data in an array

Mar.14,2021

two ideas: one is that the traversal array length of data processing in advance is 1; Define list= [] in data; this.list.push (result.imgs [0]) in js; then change the v-for to "(img,index) in list";
the second way of thinking is to restrict the traversal code directly when traversing the line to
but when there is a large amount of data, the first performance is better


1.) No loop
2. Add result.imgs if = "index=0"


Direct result.imgs [0] after the loop


use slice to generate a new array, and then v-for New array:

<div class="list_img_holder_large" v-for="(img, index) in result.imgs.slice(0,1)">
    <img :src="">
</div>

ide/list.html-sharpv-for-with-v-if" rel=" nofollow noreferrer "> just read the document carefully and add v-if to judge

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-1e473d6-44c38.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-1e473d6-44c38.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?