-
Notifications
You must be signed in to change notification settings - Fork 4.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
使用Taro.createSelectorQuery()的api在dataset中获取不到自定义data-的属性 #9302
Comments
taro-bot2
bot
added
F-react
Framework - React
T-weapp
Target - 编译到微信小程序
V-3
Version - 3.x
labels
May 10, 2021
+1 |
1 similar comment
+1 |
@const-Ly @jianqiao0313 @wen-dong 你不需要用 dataset 用 import React from 'react';
import Taro from '@tarojs/taro'
import { View } from '@tarojs/components'
interface defauleState {
content: string,
}
class Demo extends React.Component<any, defauleState> {
el = React.createRef(null)
constructor(props) {
super(props);
this.state = {
content: '',
}
}
onLoad(options) {
this.getPageData();
}
getPageData() {
Taro.request({
url: 'https://mock.gezichenshan.top/mock/5b921496de266131e288aaa6/example/ly/collect',
method:'post',
success: (res) => {
console.log(res)
if(res.data.success == 1) {
this.setState({
content: "请求成功"
}, () => {
// setTimeout(() => {
// Taro.createSelectorQuery().selectAll('.container').fields({
// dataset: true,
// size: true,
// }, function (res) {
// console.log(res)
// }).exec()
console.log('ref: ', this.el.current.props)
const dom = document.getElementById('view')
console.log('dom: ', dom.props)
// }, 100);
})
}
}
}).catch(err => {
});
}
render() {
const {content} = this.state;
return <View id='view' ref={this.el} data-index={1} data-id={123} className={'container'}>
{content}
</View>
}
}
export default Demo; |
@Chen-jj 有一个问题,我使用ref如何获取当前dom节点的位置信息? |
我的意思就是有没有办法让ref或者getElementById里面的信息与NodeRef里面的逻辑关联起来? |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
相关平台
微信小程序
复现仓库
https://github.com/const-Ly/demo/blob/main/demo.tsx
小程序基础库: 2.16.1
使用框架: React
复现步骤
1、运行这个链接的文件:https://github.com/const-Ly/demo/blob/main/demo.tsx
2、查看打印数据中dataset对象中是否包括data-自定义属性
期望结果
使用Taro.createSelectorQuery()的api在dataset中能获取到data-的属性。
实际结果
现在返回的dataset是空对象,dataset对象中并没有data-的属性
环境信息
The text was updated successfully, but these errors were encountered: