From cf77ed45f3c198d5adddebde7adafbaa7bad2731 Mon Sep 17 00:00:00 2001 From: chenjiajian <798095202@qq.com> Date: Thu, 9 Dec 2021 21:07:29 +0800 Subject: [PATCH] =?UTF-8?q?fix(shared/runtime):=20=E4=BF=AE=E5=A4=8D=20van?= =?UTF-8?q?t=20weapp=20=E5=85=BC=E5=AE=B9=E9=97=AE=E9=A2=98=EF=BC=8Cfix=20?= =?UTF-8?q?#10337?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 1. 可以传递 class 属性 2. 可以传递函数类型属性 --- packages/shared/src/template.ts | 2 ++ packages/taro-runtime/src/dom/element.ts | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/packages/shared/src/template.ts b/packages/shared/src/template.ts index 35f6b7950370..7a884a9ac59c 100644 --- a/packages/shared/src/template.ts +++ b/packages/shared/src/template.ts @@ -216,6 +216,8 @@ export class BaseTemplate { value = `:${value}` } return str + `bind${value}="eh" ` + } else if (attr === 'class') { + return str + `class="{{i.${Shortcuts.Class}}}" ` } return str + `${attr}="{{i.${toCamelCase(attr)}}}" ` diff --git a/packages/taro-runtime/src/dom/element.ts b/packages/taro-runtime/src/dom/element.ts index 1f93e51e83f0..6a1579a22c24 100644 --- a/packages/taro-runtime/src/dom/element.ts +++ b/packages/taro-runtime/src/dom/element.ts @@ -1,5 +1,5 @@ import { inject, injectable } from 'inversify' -import { isArray, isUndefined, Shortcuts, EMPTY_OBJ, warn, isString, toCamelCase } from '@tarojs/shared' +import { isArray, isUndefined, Shortcuts, EMPTY_OBJ, warn, isString, toCamelCase, isFunction } from '@tarojs/shared' import SERVICE_IDENTIFIER from '../constants/identifiers' import { TaroNode } from './node' import { NodeType } from './node_types' @@ -174,7 +174,7 @@ export class TaroElement extends TaroNode { const payload = { path: `${this._path}.${toCamelCase(qualifiedName)}`, - value + value: isFunction(value) ? () => value : value } this.hooks.modifySetAttrPayload?.(this, qualifiedName, payload)