From e4d9e67d9b051031914efa44580ce1ca80e8a142 Mon Sep 17 00:00:00 2001 From: yuche Date: Wed, 5 Dec 2018 17:16:48 +0800 Subject: [PATCH] =?UTF-8?q?feat(taroize):=20=E5=9C=A8=E7=B1=BB=E4=B8=AD?= =?UTF-8?q?=E8=B0=83=E7=94=A8=20=E5=BE=AE=E4=BF=A1=E9=92=A9=E5=AD=90?= =?UTF-8?q?=E5=87=BD=E6=95=B0=E8=BD=AC=E6=8D=A2=E4=B8=BA=E7=9B=B8=E5=BA=94?= =?UTF-8?q?=E5=9C=B0=20Taro=20=E9=92=A9=E5=AD=90=E5=87=BD=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/taroize/.gitignore | 1 + packages/taroize/src/events.ts | 2 +- packages/taroize/src/script.ts | 9 +++++++-- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/packages/taroize/.gitignore b/packages/taroize/.gitignore index cf1b9974a5b6..b8b1c1580b3e 100644 --- a/packages/taroize/.gitignore +++ b/packages/taroize/.gitignore @@ -1,3 +1,4 @@ lib t.js *.wxml +s.js \ No newline at end of file diff --git a/packages/taroize/src/events.ts b/packages/taroize/src/events.ts index f6d9cc22c5c9..879469cf7c7e 100644 --- a/packages/taroize/src/events.ts +++ b/packages/taroize/src/events.ts @@ -23,7 +23,7 @@ specialEvents.set('bindanimationstart', 'onAnimationStart') specialEvents.set('bindanimationtteration', 'onAnimationIteration') specialEvents.set('bindanimationend', 'onAnimationEnd') specialEvents.set('bindtouchforcechange', 'onTouchForceChange') -specialEvents.set('bindtap', 'onTouchForceChange') +specialEvents.set('bindtap', 'onClick') specialEvents.forEach((value, key) => { specialEvents.set(key.replace(/^bind/, 'catch'), value) }) diff --git a/packages/taroize/src/script.ts b/packages/taroize/src/script.ts index f577947ea1bd..92a8dce11d80 100644 --- a/packages/taroize/src/script.ts +++ b/packages/taroize/src/script.ts @@ -160,8 +160,13 @@ function parsePage ( } if (callee.isMemberExpression()) { const object = callee.get('object') - if (object.isIdentifier({ name: 'wx' })) { - object.replaceWith(t.identifier('Taro')) + if (object.isIdentifier()) { + const methodName = object.node.name + if (PageLifecycle.has(methodName)) { + object.replaceWith(t.identifier(PageLifecycle.get(methodName)!)) + } else if (methodName === 'wx') { + object.replaceWith(t.identifier('Taro')) + } } } },