VUE reported an error: TypeError: Cannot read property 'thumbnail' of undefined

problem description

the error is as follows

related codes

<div class="newsitem" v-for="item in newsItems">
                    <router-link :to="{path: "/newsDetail",query:{ id : item.id }}">
                        <div class="m0"><img :src="item.more.thumbnail">
                            <div class="title">{{item.post_title}}</div>
                            <div class="pubtime"><span>{{item.categories[0].name}} {{item.published_time}}</span></div>
                        </div>
                    </router-link>
                </div>

searched a lot on the Internet, tried a lot of methods did not solve, generally means to call a lot of levels of item.more.thumbnail, report an error, the page can also call up the data normally, that is, report an error!

would like to ask how to solve the problem?

Jan.08,2022

preliminary judgment is that vue cannot find the variable thumbnail. More precisely, it should be that the more under newsItems is not defined or the more under an item is not defined, and you print out newsItems, in the console to see if this is the problem.


for objects with uncertain attributes, point syntax is not recommended. It is recommended to use subscript syntax. In addition, you should fully consider the situation where attributes do not exist, such as

this means that there is no value, and there are at least two field-level errors.
the landlord takes a good look at his field data structure.

add 2018-12-06:
add if judgment before the fields used. It is estimated that Vue adds code tests for code robustness. The example of
is as follows

<add-person
    v-if="travellerTemplateRule.after && travellerTemplateRule.after.template_people"
    :isShow="isOpenAddNewMask"
    :data="travellerTemplateRule.after.template_people">
</add-person>
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-1e3c8bc-43a1c.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-1e3c8bc-43a1c.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?