Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

在observer.js中 您重写了默认的Observer.prototype 那么this.walk(data) 还能正确的找到walk这个方法吗 #26

Open
blinkMyEyesConsciously opened this issue Nov 16, 2018 · 1 comment

Comments

@blinkMyEyesConsciously
Copy link

var Observer = function Observer (value) {
this.value = value;
this.dep = new Dep();
this.vmCount = 0;
def(value, 'ob', this);
if (Array.isArray(value)) {
var augment = hasProto
? protoAugment
: copyAugment;
augment(value, arrayMethods, arrayKeys);
this.observeArray(value);
} else {
this.walk(value);
}
};

Observer.prototype.walk = function walk (obj) {
    var keys = Object.keys(obj);
    for (var i = 0; i < keys.length; i++) {
        defineReactive(obj, keys[i]);
    }
};

这是尤大的写法
你是直接用字面量的方式进行重写
在学习你的代码的过程中发现按照你的写法显示walk 为定义

@DMQ
Copy link
Owner

DMQ commented Dec 24, 2018

@blinkMyEyesConsciously 有具体的代码例子吗?这里的代码应该是没问题的

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants