Vue自定义标签

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title></title>
<script src="https://cdn.jsdelivr.net/npm/vue"></script>
</head>
<body>
<div id="app">
<ol>
<todo-item v-for='item in list' v-bind:todo="item" v-bind:key="item.id"></todo-item>
</ol>
</div>
<script>
Vue.component('todo-item',{
props:['todo'],
template:'<li>{{todo.text}}</li>'
})

var app7 = new Vue({
el:'#app',
data:{
list:[
{id:0,text:'蔬菜'},
{id:1,text:'奶露'},
{id:0,text:'aaaa'}
]
}
})
</script>
</body>
</html>

posted @ 2018-11-21 18:12  江山一族  阅读(3990)  评论(0编辑  收藏  举报