只要使用v-for循序显示和绑定按钮事件
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Vue学习</title>
<script src="./vue.js"></script>
</head>
<body>
<div id="root">
<div v-if="show">hello</div>
<input v-model="inputValue"/>
<button @click="handleClick">click</button>
<ul>
<li v-for="(item, index) of list" :key="index">{{item}}</li>
</ul>
</div>
<script>
new Vue({
el:"#root",
data:{
show:true,
list:[]
},
methods:{
handleClick:function () {
this.list.push(this.inputValue);
this.inputValue = "";
}
},
})
</script>
</body>
</html>