我不明白爲什麼我無法訪問user
對象中的數據。無法訪問Vue組件內對象的數據
{
"channel_id": 2,
"user": {
"id": 1,
"name": "Clyde Santiago",
"email": "[email protected]",
"created_at": "2017-07-25 08:10:58",
"updated_at": "2017-07-25 08:10:58"
},
"message": "ssd"
}
訪問channel_id
,user
,message
是罰款。但是,當我訪問了user
的數據也顯示
錯誤,
「的未定義無法讀取屬性‘名’」這是在我的Vue組件的HTML
<ul class="list-group"> <li class="list-group-item" v-for="conversation in conversations"> <p> {{conversation.message}} </p> <small>{{conversation.user.name}}</small> // error here </li> </ul>
什麼錯誤,這個數據是異步檢索? – Bert
您試圖訪問哪些數據? {{conversation.user}}是一個對象,所以它應該給[object Object]。 {{conversation.user.id}}會給用戶id等 – HelloWorld
「無法讀取未定義的屬性'名稱'這就是錯誤。我正在使用推送器 –