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
constMixinsKey='$$$_mixins'/** * mixin lifecycles will always be called even if you override it in subclass * @param target * @param propertyKey * @param descriptor */exportfunctionmixin(target: any,propertyKey: PropertyKey,descriptor: PropertyDescriptor){letmixins=target[MixinsKey]=target[MixinsKey]||{}Object.defineProperty(mixins,propertyKey,descriptor)descriptor.value=(f: any)=>freturndescriptor}// Custom pagify with full OO supportexportfunctionpagify(){return(Ctor: {new(): any})=>{letobj={}asanyletpage=newCtor()letmixins=page[MixinsKey]||{}for(constkeyinpage){if(typeofpage[key]==='function'&&key!=='constructor'){obj[key]=function(...args: any[]){mixins[key]&&mixins[key].apply(this,args)returnpage[key](...args)}}}obj.data=page.datalet_this: anylet{ onLoad }=objobj.onLoad=function(...args: any[]){_this=thisonLoad.call(this, ...args)}Object.defineProperty(page,'data',{get(){return_this.data}})page.setData=(...args: any[])=>{return_this.setData(...args)}Page(obj)}}
The text was updated successfully, but these errors were encountered:
最近又开始写小程序了,发现 minapp 不支持 super 关键字, mixin 不能写到顶层类上, 感觉还是很不方便,于是随手重写了下 pagify, 感觉实现上也没啥问题,不知道为啥 minapp 不支持。
The text was updated successfully, but these errors were encountered: