export const basic = Behavior({ methods: { $emit( name: string, detail?: Record, options?: WechatMiniprogram.Component.TriggerEventOption ) { this.triggerEvent(name, detail, options); }, set(data: Record) { this.setData(data); return new Promise((resolve) => wx.nextTick(resolve)); }, // high performance setData setView( this: WechatMiniprogram.Component.TrivialInstance, data: Record, callback?: () => void ) { const target: Record = {}; let hasChange = false; Object.keys(data).forEach((key) => { if (data[key] !== this.data[key]) { target[key] = data[key]; hasChange = true; } }); if (hasChange) { return this.setData(target, callback); } return callback && callback(); }, }, });