1. 程式人生 > >vue 數組對象取對象的屬性: Cannot read property 'xxxx' of undefined

vue 數組對象取對象的屬性: Cannot read property 'xxxx' of undefined

for per 想要 defined template In undefined list code

{{ list[0].name }}

list[0]沒有定義

能正確打印出想要的結果,但就是報錯,外面套個v-for就沒錯了 很費解

與異步有關,解決辦法:
    <template v-if=list[0]>
        {{ list[0].name }}
    </template>

https://www.v2ex.com/amp/t/402145

vue 數組對象取對象的屬性: Cannot read property 'xxxx' of undefined