本文共 751 字,大约阅读时间需要 2 分钟。
I want to make a program that adds and deletes items using the input tag. I wrote a program as I know, but the addition works fine, but when I delete it, an error appears. And when I check the checkbox, I want to put the text that turns red, but I tried several things and it failed. I would appreciate it if you let me know.
Documentdiv.active { color: red;}
ADD
{
{ item.name }}DELETE
new Vue({
el : '#app',
data : {
name : '',
val : [],
list : [
{ id: 1, name: 'Buy a car'},
{ id: 2, name: 'Do a homework'},
],
},
methods: {
doAdd: function() {
var max = this.list.reduce(function(a, b) {
return a > b.id ? a : b.id
}, 0)
this.list.push({
id: max + 1,
name: this.name
})
},
doRemove: function(index) {
this.list.splice(index, 1)
},
}
})
转载地址:http://eejdv.baihongyu.com/