defineReactive函数第一行

Author: HeyangzhouzzCreated Apr 29, 2019Updated Jun 8, 2021
function defineReactive (obj, key, val, cb) {
    let val = val
    Object.defineProperty(obj, key, {
        enumerable: true,
        configurable: true,
        get: ()=>{
            /*....依赖收集等....*/
            /*Github:https://github.com/answershuto*/
            return val
        },
        set:newVal=> {
            val = newVal;
            cb();/*订阅者收到消息的回调*/
        }
    })
}