没有意外只有 get,骚就骚在这儿:
- // 可变数据插桩对象,以及一系列相应的插桩方法
- const mutableInstrumentations: any = {
- get(key: any) {
- return get(this, key, toReactive)
- },
- get size() {
- return size(this)
- },
- has,
- add,
- set,
- delete: deleteEntry,
- clear,
- forEach: createForEach(false)
- }
- // 迭代器相关的方法
- const iteratorMethods = ['keys', 'values', 'entries', Symbol.iterator]
- iteratorMethods.forEach(method => {
- mutableInstrumentations[method] = createIterableMethod(method, false)
- readonlyInstrumentations[method] = createIterableMethod(method, true)
- })
- // 创建getter的函数
- function createInstrumentationGetter(instrumentations: any) {
- return function getInstrumented(
- target: any,
- key: string | symbol,
- receiver: any
- ) {
- target =
- hasOwn(instrumentations, key) && key in target ? instrumentations : target
- return Reflect.get(target, key, receiver)
- }
- }
(编辑:惠州站长网)
【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!
|