You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
/** * Augment a target Object or Array by intercepting * the prototype chain using __proto__ */functionprotoAugment(target,src: Object){/* eslint-disable no-proto */target.__proto__=src/* eslint-enable no-proto */}
/* * not type checking this file because flow doesn't play well with * dynamically accessing methods on Array prototype */import{def}from'../util/index'constarrayProto=Array.prototypeexportconstarrayMethods=Object.create(arrayProto)constmethodsToPatch=[// 这里列举的数组的方法是调用后能改变原数组的'push','pop','shift','unshift','splice','sort','reverse']/** * Intercept mutating methods and emit events */methodsToPatch.forEach(function(method){// 重写原型方法// cache original methodconstoriginal=arrayProto[method]// 调用原数组方法def(arrayMethods,method,functionmutator(...args){constresult=original.apply(this,args)constob=this.__ob__letinsertedswitch(method){case'push':
case'unshift':
inserted=argsbreakcase'splice':
inserted=args.slice(2)break}if(inserted)ob.observeArray(inserted)// 进行深度监控// notify changeob.dep.notify()// 调用数组方法后,手动通知视图更新returnresult})})
No description provided.
The text was updated successfully, but these errors were encountered: