借助v-for理解对象和对象数组

v-for就是接受对象和数组 两种

数组里面可以嵌套对象

        <span v-for="(stu,index) in students">{{index}},{{stu}}</span>

    </div>
</template>

<script>
export default{

    data(){
        return{
            students:[
                {
                    name:"aa",
                    age:28
                },
                {
                    name:"bb",
                    age:18
                }
            ]
        }
    }
}

输出就是这种

0,{ "name": "aa", "age": 28 }1,{ "name": "bb", "age": 18 }

猜你喜欢

转载自blog.csdn.net/weixin_36869329/article/details/82259073