为什么子组件中不能用v-for
来源:4-3 组件参数校验与非 props 特性
 
			目訫
2019-04-29
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <script src="https://cdn.bootcss.com/vue/2.6.6/vue.min.js"></script>
    <title>Example</title>
    <style>
        .root {
            width: 1500px;
            height: 500px;
            border: 2px solid orange;
            border-radius: 50px;
        }
    </style>
</head>
<body>
    <div id="root">
        <div class="root"></div>
        <child></child>
    </div>
    <script>
        Vue.component('child', {
            data () {
                return {
                    list: [{
                        id: 0001,
                        name: 'x',
                        age: 9
                    },{
                        id: 0002,
                        name: 'a',
                        age: 2
                    }]
                }
            },
            template: '<div v-for="item of list" :key="item.id">{{ item.name }}</div>'
        })
        let vm = new Vue({
            el: '#root'
        })
    </script>
</body>
</html>
老师,为什么这里循环不出来子组件中的list
写回答
	1回答
- 
				
				看起来没问题,应该可以渲染的,报错么 182019-04-30
相似问题
