![9169520d6df5b71c6e6a2421b1df06cd.png](https://img-blog.csdnimg.cn/img_convert/9169520d6df5b71c6e6a2421b1df06cd.png)
我们打开文件 `src/core/observer/index.js`,找到定义`defineReactive `函数的代码:
export function defineReactive ( obj: Object, key: string, val: any, customSetter?: ?Function, shallow?: boolean) { const dep = new Dep() const property = Object.getOwnPropertyDescriptor(obj, key) if (property && property.configurable === false) { return } // cater for pre-defined getter/setters const getter = property && property.get const setter = property && property.set if ((!getter || setter) && arguments.length === 2) { val = obj[key] } let childOb = !shallow && observe(val) Object.defineProperty(obj, key, { enumerable: true, configurable: true