1. 程式人生 > >vue中判斷陣列長度length報錯

vue中判斷陣列長度length報錯

{{pawnList.length>0 ? pawnList.name : ''}}

報錯:Error in render: "TypeError: Cannot read property 'length' of undefined"

 

解決辦法:

{{pawnList!== undefined && pawnList.length>0 ? pawnList.name : ''}}