1***@qq.com
1***@qq.com
  • 发布:2020-02-17 17:50
  • 更新:2021-12-16 14:07
  • 阅读:5782

uni.createSelectorQuery().in(this).select(".test"); select()里面不支持数字和中文如何解决,

分类:uni-app

uni.createSelectorQuery().in(this).select(".test");select()里面不支持数字和中文如何解决,DOMException: Failed to execute 'matches' on 'Element': '#2019-09' is not a valid selector. 有没有什么方法,我想获取dom 的top,可以在app ios 兼容的

0 关注 分享

要回复文章请先登录注册

1***@qq.com

1***@qq.com

问下有没有出现这种问题:

执行代码是这样:
const query = uni.createSelectorQuery().in(this)
query.select('.picker-scroll-mask').boundingClientRect((mask)=>{
// mask.height
this.list_height=mask.height
}).exec()


报错是这样的:
[JS Framework] Failed to execute the callback function:
14:01:37.758 TypeError: Cannot read property 'nodeId' of undefined
14:01:37.788 reportJSException >>>> exception function:__WEEX_CALL_JAVASCRIPT__, exception:JavaScript execute error!Uncaught TypeError: Cannot read property 'nodeId' of undefined

真恶心都不知道什么J8错。在android-app上运行就爆这种奇怪错误。在H5上传非常正常。
2021-12-16 14:07
2***@qq.com

2***@qq.com

回复 1***@163.com :
跨自定义组件的后代选择器:.the-ancestor >>> .the-descendant

这个在h5中不支持?
2021-04-27 14:04
1***@163.com

1***@163.com

官方文档 https://uniapp.dcloud.io/api/ui/nodes-info?id=selectorqueryselect
selector 说明:
selector 类似于 CSS 的选择器,但仅支持下列语法。
ID选择器:#the-id
class选择器(可以连续指定多个):.a-class.another-class
子元素选择器:.the-parent > .the-child
后代选择器:.the-ancestor .the-descendant
跨自定义组件的后代选择器:.the-ancestor >>> .the-descendant
多选择器的并集:#a-node, .some-other-nodes

所以你好好想想’#2019-09‘是个什么语法,select()里面不是不支持数字,而是你这个根本不是一个合法的html的id名...
2020-05-09 15:42