draggableSheet.behavior.ts 428 B

12345678910111213141516
  1. const KEY = 'draggableSheetContext' as const;
  2. export function DraggableSheetBehavior(selector: string) {
  3. return Behavior({
  4. lifetimes: {
  5. created() {
  6. this.createSelectorQuery().select(selector).node().exec(res => {
  7. (<any>this)[KEY] = res[0].node;
  8. })
  9. }
  10. }
  11. })
  12. }
  13. export function getDraggableSheetContext(this: any) {
  14. return this?.[KEY] as WechatMiniprogram.DraggableSheetContext;
  15. }