Skip to content
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 h5 无法获得 View, Text 等组件的自定义的 dataset 值 #9798

Closed
ickg5 opened this issue Jul 15, 2021 · 0 comments · Fixed by #9797 or #9858
Closed

Taro h5 无法获得 View, Text 等组件的自定义的 dataset 值 #9798

ickg5 opened this issue Jul 15, 2021 · 0 comments · Fixed by #9797 or #9858
Labels
F-react Framework - React T-h5 Target - 编译到 H5 V-3 Version - 3.x
Milestone

Comments

@ickg5
Copy link
Contributor

ickg5 commented Jul 15, 2021

相关平台

H5

复现仓库

https://github.com/taroify/taro330-dataset
浏览器版本: Chrome 91.0.4472.114
使用框架: React

复现步骤

Taro h5 无法获得 View, Text 等组件的自定义的 dataset 值

BUG 复现代码

import {Text, View} from '@tarojs/components'
import {useReady} from '@tarojs/taro';
import {useRef} from 'react';

export default function Index() {

  const viewRef = useRef<HTMLElement>()
  const textRef = useRef<HTMLElement>()
  const divRef = useRef<HTMLDivElement>(null)

  useReady(() => {
    console.log(viewRef.current?.dataset)
    console.log(textRef.current?.dataset)
    console.log(divRef.current?.dataset)
  })

  return (
    <>
      <View ref={viewRef} data-index='view-value'>View dataset</View>
      <Text ref={textRef} data-index='text-value'>Text dataset</Text>
      <div ref={divRef} data-index='div-value'>Div dataset</div>
    </>
  )
}

在 weapp 执行结果:

weapp

在 h5 执行结果:

h5

期望结果:

主要问题是 如 View,Text 这种 Taro 内置组件不支持自定的 dataset 属性。

期望结果

index: "view-value"
index: "text-value"

实际结果

index: undefined
index: undefined

环境信息

� Taro v3.3.0


  Taro CLI 3.3.0 environment info:
    System:
      OS: Windows 10
    Binaries:
      Node: 14.17.1 - C:\Programs\nodejs\node-v14.17.1-win-x64\node.EXE
      Yarn: 1.22.10 - C:\Programs\nodejs\node-v14.17.1-win-x64\yarn.CMD
      npm: 6.14.13 - C:\Programs\nodejs\node-v14.17.1-win-x64\npm.CMD

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
F-react Framework - React T-h5 Target - 编译到 H5 V-3 Version - 3.x
Projects
Archived in project
2 participants