We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
字节跳动小程序
小程序基础库: 2.89.0.0 使用框架: React
在页面组件中添加全局的点击事件 useEffect(() => { document.addEventListener('click', () => { console.log('全局点击事件'); }) }, []);
点击屏幕后触发事件
点击屏幕后没有响应
👽 Taro v3.6.8 Taro CLI 3.6.8 environment info: System: OS: macOS 12.2.1 Shell: 5.8 - /bin/zsh Binaries: Node: 14.21.3 - ~/.nvm/versions/node/v14.21.3/bin/node Yarn: 1.22.19 - ~/.nvm/versions/node/v14.21.3/bin/yarn npm: 6.14.18 - ~/.nvm/versions/node/v14.21.3/bin/npm npmPackages: @tarojs/cli: 3.6.8 => 3.6.8 @tarojs/components: 3.6.8 => 3.6.8 @tarojs/helper: 3.6.8 => 3.6.8 @tarojs/plugin-framework-react: 3.6.8 => 3.6.8 @tarojs/plugin-html: ^3.6.8 => 3.6.8 @tarojs/plugin-platform-alipay: 3.6.8 => 3.6.8 @tarojs/plugin-platform-h5: 3.6.8 => 3.6.8 @tarojs/plugin-platform-jd: 3.6.8 => 3.6.8 @tarojs/plugin-platform-qq: 3.6.8 => 3.6.8 @tarojs/plugin-platform-swan: 3.6.8 => 3.6.8 @tarojs/plugin-platform-tt: 3.6.8 => 3.6.8 @tarojs/plugin-platform-weapp: 3.6.8 => 3.6.8 @tarojs/react: 3.6.8 => 3.6.8 @tarojs/runtime: 3.6.8 => 3.6.8 @tarojs/shared: 3.6.8 => 3.6.8 @tarojs/taro: 3.6.8 => 3.6.8 @tarojs/taro-loader: 3.6.8 => 3.6.8 @tarojs/webpack5-runner: 3.6.8 => 3.6.8 babel-preset-taro: 3.6.8 => 3.6.8 eslint-config-taro: 3.6.8 => 3.6.8 react: ^18.0.0 => 18.2.0
是否taro的document对象模拟的addEventListener方法有问题
The text was updated successfully, but these errors were encountered:
小程序没有 document 或者 window,因此本身就不支持这种方式的事件监听,因此 document.addEventListener('click', handler) 不会生效。
Sorry, something went wrong.
但是Taro有模拟document对象,只是针对document.addEventListener()有问题 官网文章链接:https://docs.taro.zone/docs/taro-dom#document 本地代码调试也存在document对象nodeName: "#document"
No branches or pull requests
相关平台
字节跳动小程序
小程序基础库: 2.89.0.0
使用框架: React
复现步骤
在页面组件中添加全局的点击事件
useEffect(() => {
document.addEventListener('click', () => {
console.log('全局点击事件');
})
}, []);
期望结果
点击屏幕后触发事件
实际结果
点击屏幕后没有响应
环境信息
补充信息
是否taro的document对象模拟的addEventListener方法有问题
The text was updated successfully, but these errors were encountered: