<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
<title>hello</title>
</head>
<body>
<div id="app">
<input type="text" v-model="val" @keyup.enter=add>
<ul>
<li v-for="(a,index) in arr">{{a}} <button @click=remove(index)>删除</button></li>
</ul>
</div>
<!-- <script src="node_modules\vue\dist\vue.js"></script> -->
<script src="https://cdn.jsdelivr.net/npm/vue@2.5.17/dist/vue.js"></script>
<script>
let vm = new Vue({
el: '#app',
methods:{
add(e){
this.arr.unshift(this.val);
this.val = '';
},
remove(val){
this.arr=this.arr.filter((item,index)=>index != val);
}
},
data: {
arr:[],
val: ''
}
})
</script>
</body>
</html>