javascript - How to solve the problem that there is a key in the data in the v-for loop in vue but no error is reported
某草草
某草草 2017-06-12 09:29:14
0
2
741

<!DOCTYPE html>
<html lang="en">
<head>

<meta charset="UTF-8">
<title>Document</title>
<script src="vue.js"></script>

</head>
<body>

<p id="box">
    <ul>
        <li v-for="item in arr">
            <p>{{item.name}}</p>
            <p>{{item.age.age2}}</p>
        </li>
    </ul>
</p>

</body>
</html>
<script type="text/javascript">

var vm = new Vue({
    el:'#box',
    data:{
        arr:[{name:'张三',age:{age2:45},},
            {name:'王五'}]
    }
})

</script>
If part of the data provided by the background does not have the age attribute, an error will be reported through the v-for loop in the document

某草草
某草草

reply all(2)
三叔

If it is displayed, it is fine if it is not displayed.

<li v-for="item in arr">
    <p>{{item.name}}</p>
    <p>{{item.age?item.age.age2:''}}</p>
</li>
过去多啦不再A梦

There may not be age2
{{item.age && item.age.age2 ? item.age.age2 :''}}

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template