<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title></title>
<script src="./vue.js"></script>
</head>
<body>
<div id="root">
<input v-model="inputValue" />
<button @click="change">提交</button>
<ul>
<li v-for="(item,index) of list":key="index">{{item}}</li>
</ul>
</div>
<script>
new Vue({
el:"#root",
data:{
inputValue:'',
list:[]
},
methods:{
change:function(){
this.list.push(this.inputValue);
this.inputValue='' //将"input”放入list里面之后将其初始为空
}
}
})
</script>
</body>
</html>
VUE(todolist功能开发)
最新推荐文章于 2022-02-23 20:36:26 发布