From 5a2c58ed87c700d3bcbbcc7b46bc5a6d56bd1619 Mon Sep 17 00:00:00 2001 From: fxy060608 Date: Mon, 24 Jan 2022 11:19:00 +0800 Subject: [PATCH] fix(mp-weixin): canvas with touch event (#3209) (question/138565) --- .../uni-mp-weixin/__tests__/component.spec.ts | 28 +++++++++++++++++++ packages/uni-mp-weixin/dist/uni.compiler.js | 15 ++++++++-- .../uni-mp-weixin/src/compiler/options.ts | 15 ++++++++-- 3 files changed, 54 insertions(+), 4 deletions(-) diff --git a/packages/uni-mp-weixin/__tests__/component.spec.ts b/packages/uni-mp-weixin/__tests__/component.spec.ts index ed988fd00..738120eaa 100644 --- a/packages/uni-mp-weixin/__tests__/component.spec.ts +++ b/packages/uni-mp-weixin/__tests__/component.spec.ts @@ -107,6 +107,34 @@ describe('mp-weixin: transform component', () => { ``, `(_ctx, _cache) => { return { a: _ctx.id } +}` + ) + assert( + ``, + ``, + `(_ctx, _cache) => { + return { a: _o(_ctx.touchstart) } +}` + ) + assert( + ``, + ``, + `(_ctx, _cache) => { + return { a: _o(_ctx.touchmove) } +}` + ) + assert( + ``, + ``, + `(_ctx, _cache) => { + return { a: _o(_ctx.touchcancel) } +}` + ) + assert( + ``, + ``, + `(_ctx, _cache) => { + return { a: _o(_ctx.touchend) } }` ) assert( diff --git a/packages/uni-mp-weixin/dist/uni.compiler.js b/packages/uni-mp-weixin/dist/uni.compiler.js index 286ad624c..56a2c9df6 100644 --- a/packages/uni-mp-weixin/dist/uni.compiler.js +++ b/packages/uni-mp-weixin/dist/uni.compiler.js @@ -81,8 +81,19 @@ const miniProgram = { }, directive: 'wx:', lazyElement: { - canvas: [{ name: 'bind', arg: ['canvas-id', 'id'] }], - editor: [{ name: 'on', arg: ['ready'] }], + canvas: [ + { name: 'bind', arg: ['canvas-id', 'id'] }, + { + name: 'on', + arg: ['touchstart', 'touchmove', 'touchcancel', 'touchend'], + }, + ], + editor: [ + { + name: 'on', + arg: ['ready'], + }, + ], // iOS 平台需要延迟 textarea: [{ name: 'on', arg: ['input'] }], }, diff --git a/packages/uni-mp-weixin/src/compiler/options.ts b/packages/uni-mp-weixin/src/compiler/options.ts index 45c349f61..cefc8f70d 100644 --- a/packages/uni-mp-weixin/src/compiler/options.ts +++ b/packages/uni-mp-weixin/src/compiler/options.ts @@ -37,8 +37,19 @@ export const miniProgram: MiniProgramCompilerOptions = { }, directive: 'wx:', lazyElement: { - canvas: [{ name: 'bind', arg: ['canvas-id', 'id'] }], - editor: [{ name: 'on', arg: ['ready'] }], + canvas: [ + { name: 'bind', arg: ['canvas-id', 'id'] }, + { + name: 'on', + arg: ['touchstart', 'touchmove', 'touchcancel', 'touchend'], + }, + ], + editor: [ + { + name: 'on', + arg: ['ready'], + }, + ], // iOS 平台需要延迟 textarea: [{ name: 'on', arg: ['input'] }], }, -- GitLab