From 6cda94c18fe05a67c68fcde87c3716c3cb3f2839 Mon Sep 17 00:00:00 2001 From: luckyadam Date: Thu, 11 Jul 2019 14:22:21 +0800 Subject: [PATCH] =?UTF-8?q?fix(taro-quickapp):=20=E5=85=BC=E5=AE=B9?= =?UTF-8?q?=E5=90=84=E7=A7=8D=E4=BA=8B=E4=BB=B6=E7=BB=91=E5=AE=9A=E4=BC=A0?= =?UTF-8?q?=E5=8F=82=E6=83=85=E5=86=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/taro-quickapp/src/component.js | 10 ++++++---- packages/taro-quickapp/src/create-component.js | 4 ++-- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/packages/taro-quickapp/src/component.js b/packages/taro-quickapp/src/component.js index 320c9f5cc095..52db16e76f81 100644 --- a/packages/taro-quickapp/src/component.js +++ b/packages/taro-quickapp/src/component.js @@ -1,6 +1,7 @@ import { internal_safe_get as safeGet } from '@tarojs/taro' + import { enqueueRender } from './render-queue' import { updateComponent } from './lifecycle' @@ -94,11 +95,12 @@ export default class BaseComponent { __arguments: args } const detail = {} - if (this.$scope._externalBinding) { - const tempalateAttr = this.$scope._externalBinding.template.attr - Object.keys(tempalateAttr).forEach(item => { + const externalBinding = this.$scope._externalBinding + const attr = this.$scope._attr || this.$scope.attr || (externalBinding && externalBinding.template.attr) + if (attr) { + Object.keys(attr).forEach(item => { if (/^data/.test(item)) { - detail[item.replace(/^data/, '')] = tempalateAttr[item] + detail[item.replace(/_/g, '').replace(/^data/, '')] = typeof attr[item] === 'function' ? attr[item]() : attr[item] } }) } diff --git a/packages/taro-quickapp/src/create-component.js b/packages/taro-quickapp/src/create-component.js index f701e435a9b8..010ad9fefa4c 100644 --- a/packages/taro-quickapp/src/create-component.js +++ b/packages/taro-quickapp/src/create-component.js @@ -88,7 +88,7 @@ function processEvent (eventHandlerName, obj) { const dataset = {} const currentTarget = event.currentTarget const vm = currentTarget._vm || (currentTarget._target ? currentTarget._target._vm : null) - const attr = vm ? vm._externalBinding.template.attr : currentTarget._attr + const attr = vm ? vm._externalBinding.template.attr : (currentTarget._attr || currentTarget.attr) if (attr) { Object.keys(attr).forEach(key => { if (/^data/.test(key)) { @@ -330,6 +330,6 @@ export default function createComponent (ComponentClass, isPage) { } bindStaticFns(componentConf, ComponentClass) bindProperties(componentConf, ComponentClass) - ComponentClass['$$events'] && bindEvents(componentConf, ComponentClass['$$events']) + ComponentClass['taroPrivateEvents'] && bindEvents(componentConf, ComponentClass['taroPrivateEvents']) return componentConf }