2.2
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title></title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" type="text/css" media="screen" href="main.css">
<script src="main.js"></script>
</head>
<body>
<div id="app">
{{message}}
<ol>
<todo-list v-for="item in list" v-bind:todo="item" v-bind:key="item.id"></todo-list>
</ol>
</div>
<script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
<script>
Vue.component('todo-list', {
props: ['todo'],
template: '<li class="text">{{todo.text}}</li>'
})
var app = new Vue({
el: '#app',
data: {
message: 'hello Vue!',
list: [{
id: 0,
text: '读书'
}, {
id: 1,
text: '写字'
}, {
id: 2,
text: '看电视'
}
]
}
})
</script>
</div>
</body>
</html>