
- 发布:2020-10-08 13:51
- 更新:2020-12-11 17:30
- 阅读:2416
产品分类: uniapp/App
PC开发环境操作系统: Windows
PC开发环境操作系统版本号: windows10
HBuilderX类型: 正式
HBuilderX版本号: 2.8.13
手机系统: 全部
手机系统版本号: Android 10
手机厂商: 华为
页面类型: vue
打包方式: 云端
项目创建方式: HBuilderX
测试过的手机:
示例代码:
getFields() {
console.log('id')
var ininin = null
wx.createSelectorQuery().select('#the-id').fields({
dataset: true,
size: true,
scrollOffset: true,
properties: ['scrollX', 'scrollY'],
computedStyle: ['margin', 'backgroundColor', 'font-size', 'Color'],
context: true,
node: true,
}, function(res) {
res.dataset // 节点的dataset
res.width // 节点的宽度
res.height // 节点的高度
res.scrollLeft // 节点的水平滚动位置
res.scrollTop // 节点的竖直滚动位置
res.scrollX // 节点 scroll-x 属性的当前值
res.scrollY // 节点 scroll-y 属性的当前值
// 此处返回指定要返回的样式名
res.margin
res.backgroundColor
res.Color
res.context // 节点对应的 Context 对象
console.log(res)
}).exec()
},
getFields() {
console.log('id')
var ininin = null
wx.createSelectorQuery().select('#the-id').fields({
dataset: true,
size: true,
scrollOffset: true,
properties: ['scrollX', 'scrollY'],
computedStyle: ['margin', 'backgroundColor', 'font-size', 'Color'],
context: true,
node: true,
}, function(res) {
res.dataset // 节点的dataset
res.width // 节点的宽度
res.height // 节点的高度
res.scrollLeft // 节点的水平滚动位置
res.scrollTop // 节点的竖直滚动位置
res.scrollX // 节点 scroll-x 属性的当前值
res.scrollY // 节点 scroll-y 属性的当前值
// 此处返回指定要返回的样式名
res.margin
res.backgroundColor
res.Color
res.context // 节点对应的 Context 对象
console.log(res)
}).exec()
},
操作步骤:
直接运行就可以 APP和小程序返回结果不一致
直接运行就可以 APP和小程序返回结果不一致
预期结果:
dataset: {}
width: 312
height: 170
scrollLeft: 0
scrollTop: 0
scrollWidth: 0
scrollHeight: 0
margin: "0px"
backgroundColor: "rgba(0, 0, 0, 0.41)"
font-size: "40px"
nodeCanvasType: ""
dataset: {}
width: 312
height: 170
scrollLeft: 0
scrollTop: 0
scrollWidth: 0
scrollHeight: 0
margin: "0px"
backgroundColor: "rgba(0, 0, 0, 0.41)"
font-size: "40px"
nodeCanvasType: ""
实际结果:
"height": 170,
"scrollTop": 0,
"width": 312,
"scrollLeft": 0,
"dataset": {}
"height": 170,
"scrollTop": 0,
"width": 312,
"scrollLeft": 0,
"dataset": {}
bug描述:
API地址
方法内的可选参数 computedStyle 在app内无任何返回结果,但是小程序内是正常的。已经有人反馈小一年了,到现在都没解决到。

Kyunwooooo - 前端小盆友
query.fields({
context: true
}, data => {
console.log("得到节点信息", data);
}).exec()
传context 也拿不到值呢

bug确认,已加分,后续修复
-
ahao8363 (作者)
希望尽快修复,nodesRef.fields方法多数情况下用于生成操作海报等应用,目前市场优秀的 APP端 海报生成 图片制作 在线编辑生成的插件市场空白就是因为这个方法。
2020-10-13 04:01
Kyunwooooo
返回了null
2020-12-11 17:31