加入收藏 | 设为首页 | 会员中心 | 我要投稿 惠州站长网 (https://www.0752zz.com.cn/)- 办公协同、云通信、物联设备、操作系统、高性能计算!
当前位置: 首页 > 建站 > 正文

茶余饭后聊聊 Vue3.0 响应式数据那些事儿

发布时间:2019-11-04 15:49:10 所属栏目:建站 来源:佚名
导读:副标题#e# 别再更新了,实在是学不动了这句话道出了多少前端开发者的心声,不幸的是 Vue 的作者在国庆区间发布了 Vue3.0 的 pre-Aplha 版本,这意味着 Vue3.0 快要和我们见面了。既来之则安之,扶我起来我要开始讲了。Vue3.0 为了达到更快、更

没有意外只有 get,骚就骚在这儿:

  1. // 可变数据插桩对象,以及一系列相应的插桩方法 
  2. const mutableInstrumentations: any = { 
  3.   get(key: any) { 
  4.     return get(this, key, toReactive) 
  5.   }, 
  6.   get size() { 
  7.     return size(this) 
  8.   }, 
  9.   has, 
  10.   add, 
  11.   set, 
  12.   delete: deleteEntry, 
  13.   clear, 
  14.   forEach: createForEach(false) 
  15. // 迭代器相关的方法 
  16. const iteratorMethods = ['keys', 'values', 'entries', Symbol.iterator] 
  17. iteratorMethods.forEach(method => { 
  18.   mutableInstrumentations[method] = createIterableMethod(method, false) 
  19.   readonlyInstrumentations[method] = createIterableMethod(method, true) 
  20. }) 
  21. // 创建getter的函数 
  22. function createInstrumentationGetter(instrumentations: any) { 
  23.   return function getInstrumented( 
  24.     target: any, 
  25.     key: string | symbol, 
  26.     receiver: any 
  27.   ) { 
  28.     target = 
  29.       hasOwn(instrumentations, key) && key in target ? instrumentations : target 
  30.     return Reflect.get(target, key, receiver) 
  31.   } 

(编辑:惠州站长网)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

推荐文章
    热点阅读