From ac36a3e5c62c73ab02a52370beed51c7ac07a8ac Mon Sep 17 00:00:00 2001 From: fxy060608 Date: Thu, 13 Oct 2022 19:56:12 +0800 Subject: [PATCH] fix(mp-weixin): scroll-view with drag event (#3921) --- .../uni-mp-weixin/__tests__/component.spec.ts | 37 +++++++++++++++++++ .../uni-mp-weixin/src/compiler/options.ts | 6 +++ 2 files changed, 43 insertions(+) diff --git a/packages/uni-mp-weixin/__tests__/component.spec.ts b/packages/uni-mp-weixin/__tests__/component.spec.ts index 50c613f3f..ea825c47e 100644 --- a/packages/uni-mp-weixin/__tests__/component.spec.ts +++ b/packages/uni-mp-weixin/__tests__/component.spec.ts @@ -188,6 +188,43 @@ describe('mp-weixin: transform component', () => { ``, `(_ctx, _cache) => { return _e({ a: _ctx.ok1 }, _ctx.ok1 ? { b: _ctx.id } : _ctx.ok2 ? {} : { d: _ctx.id }, { c: _ctx.ok2 }) +}` + ) + }) + test('lazy element: scroll-view', () => { + assert( + ``, + ``, + `(_ctx, _cache) => { + return {} +}` + ) + assert( + ``, + ``, + `(_ctx, _cache) => { + return { a: _o(_ctx.d) } +}` + ) + assert( + ``, + ``, + `(_ctx, _cache) => { + return { a: _o(_ctx.d) } +}` + ) + assert( + ``, + ``, + `(_ctx, _cache) => { + return { a: _o(_ctx.d) } +}` + ) + assert( + ``, + ``, + `(_ctx, _cache) => { + return { a: _o(_ctx.d), b: _o(_ctx.d), c: _o(_ctx.d) } }` ) }) diff --git a/packages/uni-mp-weixin/src/compiler/options.ts b/packages/uni-mp-weixin/src/compiler/options.ts index 06e45436b..31918355f 100644 --- a/packages/uni-mp-weixin/src/compiler/options.ts +++ b/packages/uni-mp-weixin/src/compiler/options.ts @@ -52,6 +52,12 @@ export const miniProgram: MiniProgramCompilerOptions = { arg: ['ready'], }, ], + 'scroll-view': [ + { + name: 'on', + arg: ['dragstart', 'dragging', 'dragend'], + }, + ], // iOS 平台需要延迟 input: [{ name: 'bind', arg: ['type'] }], textarea: [{ name: 'on', arg: ['input'] }], -- GitLab