| | |
| | | handleBindWechat(result.wxcode); |
| | | } |
| | | }; |
| | | |
| | | |
| | | /** |
| | | * 返回一个对象,给 parent 调用 |
| | | * 此对象包含多个函数 |
| | | * @returns |
| | | */ |
| | | const childCallObj = { |
| | | /** @description 测试函数 */ |
| | | test: (msg: string) => { |
| | | console.log('test 函数来自 child', msg); |
| | | }, |
| | | execute: (obj: any) => { |
| | | console.log('execute 函数来自 child', obj); |
| | | }, |
| | | }; |
| | | export class ParentRegister { |
| | | static notify = null; |
| | | static setRegisterFunc() { |
| | | if (!window.parent) return; |
| | | (window as any).registerNotifyFunction = (notifyFunc: any) => { |
| | | ParentRegister.notify = notifyFunc; |
| | | return childCallObj; |
| | | }; |
| | | } |
| | | |
| | | static updateChildCallObj(key:string,callback:Function) { |
| | | childCallObj[key] = callback; |
| | | } |
| | | } |
| | | |
| | | |
| | | window.callObj = childCallObj; |