MVVM -Model View ViewModel
ViewModel联系View和Model
<!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">
<title>to-dol-list vue</title>
</head>
<body>
<!-- view -->
<div id="app">
<div>
<input v-model="title">
<button v-on:click="add">submit</button>
</div>
<ul>
<li v-for="item in list">{{item}}</li>
</ul>
</div>
</body>
<script src="https://cdn.jsdelivr.net/npm/vue"></script>
<script>
//model数据
var data={
title:'',
list:[]
}
//VM
var vm=new Vue({
el:'#app',
data:data,
methods:{
add:function(){
this.list.push(this.title);
this.title=''
}
}
})
</script>
</html>
三要素:响应式/模版解析引擎/渲染