419 v-if 和 v-for结合使用

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

<head>
    <meta charset="UTF-8">
    <title>Document</title>
</head>

<body>
    <div id="app">
        <div v-if='v==13' v-for='(v,k,i) in obj'>{{v + '---' + k + '---' + i}}</div>
    </div>

    <script type="text/javascript" src="js/vue.js"></script>
    <script type="text/javascript">
        // 使用原生js遍历对象
        var obj = {
            uname: 'lisi',
            age: 12,
            gender: 'male'
        }

        for (var key in obj) {
            console.log(key, obj[key])
        }

        // 循环结构
        var vm = new Vue({
            el: '#app',
            data: {
                obj: {
                    uname: 'zhangsan',
                    age: 13,
                    gender: 'female'
                }
            }
        });
    </script>
</body>

</html>

posted on 2020-03-26 13:39  冲啊!  阅读(77)  评论(0编辑  收藏  举报

导航