Vue v-for loops an array. The key value reports an error, but the data is displayed normally.

A carousel component loops an array of pictures. This data can be displayed normally in the carousel chart, but there is an error report that is not clear.

            <swiper :options="swiperOption" class="swiper-box">
                <swiper-slide class="swiper-item" v-for="item in srcList" key="item">
                    <img :src="item.src" alt="...">
                </swiper-slide>
                <div class="swiper-pagination" slot="pagination"></div>
            </swiper>

there are also wavy lines in the editor:

clipboard.png

import



clipboard.png

Sep.02,2021

you can't write this key like this, should you add: Ah

<swiper :options="swiperOption" class="swiper-box">
    <swiper-slide class="swiper-item" v-for="item in srcList" :key="item">
        <img :src="item.src" alt="...">
    </swiper-slide>
    <div class="swiper-pagination" slot="pagination"></div>
</swiper>

clipboard.png

the wavy line should be: key = "item". Try it.


the object you passed to key is {}, not a string. If the item does not have a unique identification field, then the key is removed, and there should be no problem if you do not have to pass a value.


if you make a mistake, you need to add before key : key


v-for using key,: key;
srcList is an array, and item, whose key value cannot be of data type Object should bind the next attribute of item object. This attribute cannot be repeated, otherwise an error will still occur. You can change it to "(item,index) in srcList": key= "index"), the index in the index object array. It will not repeat and will not report two problems


. First, the main city key is added before: key,. Secondly, the key binds the index and the single field of the id class, and the object is also prone to problems. It is recommended to standardize the format of v-for when using vmurfort = "(item,index) in Array": key= "index"

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