dcloudio / dcloudio/uni-app

【bug】获取节点信息uni.createSelectorQuery().selectAll("#id").fields未包含 properties 的bug APP内不返回信息 小程序内正常

Open
#3,300 2 comments 0 reactions 1 assignee Claimed by @Otto-J View on GitHub
h5 提供了复现方案
Dominant language
JavaScript
Stars
41.6k
Forks
3.7k
Avg merge
7h 6m
Merged PRs (30d)
6

Description

**问题描述**
uni.createSelectorQuery().selectAll("#id").fields方法内的可选参数 properties 在app内无任何返回结果,但是小程序内是正常的

**复现步骤**

var K = {
dataset: true,
size: true,
rect: true,
computedStyle: ["fontFamily", "fontSize", "fontStyle", "fontWeight"],
node: true,
properties: ["checked", "color", "disabled", "icon", "mode", "placeholder", "placeholderStyle",
"placeholderClass", "plain", "src", "style", "type", "value"
]
};
uni.createSelectorQuery().selectAll("#id")
.fields(K, data => {
console.log("得到节点信息" + JSON.stringify(data));
console.log("节点的宽为" + data.width);
}).exec();

**预期结果**
bottom: 124.78125
dataset: {type: "input"}
disabled: true
fontFamily: "UICTFontTextStyleBody"
fontSize: "14px"
fontStyle: "normal"
fontWeight: "400"
height: 22.390625
left: 0
nodeCanvasType: "text"
placeholder: ""
placeholderClass: ""
placeholderStyle: ""
right: 375
top: 102.390625
type: "text"
value: "12345"
width: 375

**实际结果**
{
"bottom": 177.5625,
"height": 22.390625,
"fontSize": "16px",
"fontWeight": "normal",
"width": 428,
"fontFamily": "\"PingFang SC\", Arial, \"Hiragino Sans GB\", \"Microsoft YaHei\", sans-serif",
"left": 0,
"dataset": {
"type": "input"
},
"right": 428,
"top": 155.171875,
"fontStyle": "normal"
}

**系统信息:**
- 发行平台: App
- 操作系统 [如 iOS 15、Android 10.0]
- HBuilderX版本 3.3.11.20220209及之前都不行
- uni-app版本 [如使用Vue-cli创建/运行项目,则提供`npm run info`的运行结果]
- 设备信息 华为P30Pro,苹果12Pro

**补充信息**

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.