数组双向绑定失效,的未来元素绑定失效,以及$index未定义怎么解决
-
{{ child }}
在child输入框中输入字符能改变第一个元素 的内容 ,但是后来增加的未来元素的内容不会改变
$(function () {
var person = {
name: '',
children: [{name:""}]
}
var vm = new Vue({
el: "#example",
data: person,
methods: {
addChild: function (index) {
this.children.splice(index+1, 0, '')
},
removeChild: function (index) {
console.log(index)
this.children.splice(index , 1)
},
getData: function () {
console.log(this.children);
return this
}
}
})
$('.btn').click(function () {
person.name = "asdf";
})
})
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
外国友人给出了答案 https://jsfiddle.net/psteele/...
你的原意应该是这个吧, 用vue.js2.0应该这样写