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

在Android 上(华为P20)onClick 中使用e.stopPropagation() 阻止事件冒泡,同时调用会导致组件重新Render的方法,阻止事件冒泡会失效 #7509

Closed
allendongyx opened this issue Sep 3, 2020 · 2 comments
Labels
F-react Framework - React T-weapp Target - 编译到微信小程序 V-3 Version - 3.x

Comments

@allendongyx
Copy link

相关平台

微信小程序

小程序基础库: 2.11.3
使用框架: React

复现步骤

          <RngLoginButton>
            <View
              className={styles.rightView}
              onClick={e => {
                e.stopPropagation()
                // 通过加入定时器解决了,但是有没有更好的办法呢
                setTimeout(() => {
        
                  if (data.isLike === 1) {
                    onUnLike(data)  // 这里会导致组件重新render
                  } else {
                    onLike(data)  // 这里会导致组件重新render
                  }
                }, 100)
              }}
            >
              {/* 爱心图标 */}
              {data.isLike === 1 ? (
                <View className={styles.imgBox}>
                  <View className={styles.rightText1}>{data.likes}</View>
                  <RngIcon name='yidianzan' iconSize='36' />
                </View>
              ) : (
                <View className={styles.imgBox}>
                  <View className={styles.rightText2}>{data.likes}</View>
                  <RngIcon name='weidianzan' iconSize='36' />
                </View>
              )}
            </View>
          </RngLoginButton>

期望结果

阻止事件冒泡

实际结果

android上没有阻止,华为p20

环境信息

👽 Taro v3.0.8


  Taro CLI 3.0.8 environment info:
    System:
      OS: macOS 10.14.6
      Shell: 3.2.57 - /bin/bash
    Binaries:
      Node: 10.21.0 - ~/.nvm/versions/node/v10.21.0/bin/node
      Yarn: 1.22.4 - ~/.nvm/versions/node/v10.21.0/bin/yarn
      npm: 6.14.4 - ~/.nvm/versions/node/v10.21.0/bin/npm
    npmPackages:
      @tarojs/cli: 3.0.8 => 3.0.8 
      @tarojs/components: 3.0.8 => 3.0.8 
      @tarojs/mini-runner: 3.0.8 => 3.0.8 
      @tarojs/react: 3.0.8 => 3.0.8 
      @tarojs/runtime: 3.0.8 => 3.0.8 
      @tarojs/taro: 3.0.8 => 3.0.8 
      @tarojs/webpack-runner: 3.0.8 => 3.0.8 
      babel-preset-taro: 3.0.8 => 3.0.8 
      eslint-config-taro: 3.0.8 => 3.0.8 
      react: ^16.10.0 => 16.13.1 
      taro-ui: ^3.0.0-alpha.3 => 3.0.0-alpha.3 
@taro-bot2 taro-bot2 bot added F-react Framework - React T-weapp Target - 编译到微信小程序 V-3 Version - 3.x labels Sep 3, 2020
@Chen-jj
Copy link
Contributor

Chen-jj commented Sep 3, 2020

@allendongyx 提供一下完整可运行的 demo

@allendongyx
Copy link
Author

@Chen-jj 目前就用setTimeout解决了,暂时先不管啦~

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
F-react Framework - React T-weapp Target - 编译到微信小程序 V-3 Version - 3.x
Projects
None yet
Development

No branches or pull requests

2 participants