MVVM
{{ getHelloWord }}
change model
var vm = new MVVM({
el: '#mvvm-app',
data: {
someStr: 'hello ',
className: 'btn',
htmlStr: 'red',
child: {
someStr: 'World !'
}
},
computed: {
getHelloWord: function() {
return this.someStr + this.child.someStr;
}
},
methods: {
clickBtn: function(e) {
var randomStrArr = ['childOne', 'childTwo', 'childThree'];
this.child.someStr = randomStrArr[parseInt(Math.random() * 3)];
}
}
});
vm.$watch('child.someStr', function() {
console.log(arguments);
});
一键复制
编辑
Web IDE
原始数据
按行查看
历史