From 1989860e1c87a9e55b9fe353fce1c531ff8ae74c Mon Sep 17 00:00:00 2001 From: yurj26 <1816387074@qq.com> Date: Wed, 22 Feb 2023 14:32:49 +0800 Subject: [PATCH] =?UTF-8?q?fix(app=E3=80=81h5):=20nodesRef.fields=20suppor?= =?UTF-8?q?t=20properties=20(question/163535)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../subscribe/api/request-component-info.js | 20 +++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/src/core/view/bridge/subscribe/api/request-component-info.js b/src/core/view/bridge/subscribe/api/request-component-info.js index 8b54b716dc..62d0cd1de7 100644 --- a/src/core/view/bridge/subscribe/api/request-component-info.js +++ b/src/core/view/bridge/subscribe/api/request-component-info.js @@ -2,6 +2,10 @@ import { getTargetDataset } from 'uni-helpers/index' +import { + camelize +} from 'uni-shared' + import getWindowOffset from 'uni-platform/helpers/get-window-offset' import { @@ -62,14 +66,18 @@ function getNodeInfo (el, fields) { info.height = rect.height } } - // TODO 组件 props if (Array.isArray(fields.properties)) { - fields.properties.forEach(prop => { - prop = prop.replace(/-([a-z])/g, function (e, t) { - return t.toUpperCase() + const props = el.__vue__ && el.__vue__.$props + if (props) { + fields.properties.forEach(prop => { + if (typeof prop === 'string') { + prop = camelize(prop) + if (props[prop] != null) { + info[prop] = props[prop] + } + } }) - // props - }) + } } if (fields.scrollOffset) { if (el.tagName === 'UNI-SCROLL-VIEW' && el.__vue__ && el.__vue__.getScrollPosition) { -- GitLab