xiaofuzi / re-vue

rewrite vue.js

Home Page:https://github.com/xiaofuzi/deep-in-vue

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

对象监听问题

everlose opened this issue · comments

binding.js 第94行监听对象

else if (isObj) {
    for (let prop in value) {
        self.value[prop] = value[prop];
    }
} 

存在一种情况,比如说

<p v-text="obj.testA"></p>
var opts = {
    el: '#app',
    data: {
        obj: {
            testA: 'hello world'
        }
    },
    ready () {
        this.obj = {testB: '441'};
    }
};
var mvvm = new TinyVue(opts);

此刻上面的html仍然输入的是hello world,obj 整个变了却没有影响到 obj.testA,因为遍历的时候没有给它赋值