提交 5a2c58ed 编写于 作者: fxy060608's avatar fxy060608

fix(mp-weixin): canvas with touch event (#3209) (question/138565)

上级 dd274ccf
......@@ -107,6 +107,34 @@ describe('mp-weixin: transform component', () => {
`<block wx:if="{{r0}}"><canvas canvas-id="{{a}}"/></block>`,
`(_ctx, _cache) => {
return { a: _ctx.id }
}`
)
assert(
`<canvas @touchstart="touchstart"/>`,
`<block wx:if="{{r0}}"><canvas bindtouchstart="{{a}}"/></block>`,
`(_ctx, _cache) => {
return { a: _o(_ctx.touchstart) }
}`
)
assert(
`<canvas @touchmove="touchmove"/>`,
`<block wx:if="{{r0}}"><canvas bindtouchmove="{{a}}"/></block>`,
`(_ctx, _cache) => {
return { a: _o(_ctx.touchmove) }
}`
)
assert(
`<canvas @touchcancel="touchcancel"/>`,
`<block wx:if="{{r0}}"><canvas bindtouchcancel="{{a}}"/></block>`,
`(_ctx, _cache) => {
return { a: _o(_ctx.touchcancel) }
}`
)
assert(
`<canvas @touchend="touchend"/>`,
`<block wx:if="{{r0}}"><canvas bindtouchend="{{a}}"/></block>`,
`(_ctx, _cache) => {
return { a: _o(_ctx.touchend) }
}`
)
assert(
......
......@@ -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'] }],
},
......
......@@ -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'] }],
},
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册