Skip to content

4.0.7 react webpack支付宝小程序View无法触发onClick #16812

@yamlling

Description

@yamlling

相关平台

支付宝小程序

复现仓库

https://gitee.com/yamlling_admin/taro-react-taroui.git
小程序基础库: 2.9.30
使用框架: React

复现步骤

逻辑代码
`
const login = () => {

if (!checked) {
  showToast({
    title: '请先同意用户协议',
    icon: 'none',
    duration: 2000
  })
  return
}
if (!mobile) {
  showToast({
    title: '请输入手机号码',
    icon: 'none',
    duration: 2000
  })
  return
}

if (login_type === '短信登录') {
  if (!checkCode) {
    showToast({
      title: '请输入验证码',
      icon: 'none',
      duration: 2000
    })
    return
  }
}
if (login_type === '账号登录') {
  if (!password) {
    showToast({
      title: '请输入密码',
      icon: 'none',
      duration: 2000
    })
    return
  }

  // 检测密码只能为数字和英文字母
  let reg = /^[A-Za-z0-9]+$/
  if (!reg.test(password)) {
    showToast({
      title: '密码只能为数字和英文字母',
      icon: 'none',
      duration: 2000
    })
  }
}


mobileLogin({
  mobile,
  checkCode,
  password,
  loginType: login_type === '短信登录' ? 2 : 1,
  custLoginName: mobile,
})
  .then(async res => {
    await product_car_info({
      size: 10,
      current: 1
    }).then(res => {
      let num = res.data.total
      dispatch('car', { type: 'SET_CAR', payload: { num: num } })
    });
    reLaunch({
      url: '/pages/login-result/index'
    })
  })
  .catch(err => {
    if (err.msg == '业务异常: 会员密码不正确,请重新登录或选用其他方式登录') {
      showToast({
        title: '账号密码错误',
        icon: 'error',
        duration: 2000
      })
    } else {
      showToast({
        title: err.msg,
        icon: 'error',
        duration: 2000
      })
    }
  })

}
`

模板代码
<View className="btn mt-[42px] mb-[54px] flex justify-center items-center bg-def color-black" onClick={login} > 登录 </View>

期望结果

能正常触发点击事件

实际结果

无法触发点击事件

环境信息

👽 Taro v4.0.7


  Taro CLI 4.0.7 environment info:
    System:
      OS: Windows 11 10.0.26100
    Binaries:
      Node: 18.20.4 - C:\Program Files\nodejs\node.EXE
      Yarn: 1.22.22 - C:\Program Files\nodejs\yarn.CMD
      npm: 10.7.0 - C:\Program Files\nodejs\npm.CMD
    npmPackages:
      @tarojs/cli: 4.0.7 => 4.0.7
      @tarojs/components: 4.0.7 => 4.0.7
      @tarojs/helper: 4.0.7 => 4.0.7
      @tarojs/plugin-framework-react: 4.0.7 => 4.0.7
      @tarojs/plugin-platform-alipay: 4.0.7 => 4.0.7
      @tarojs/plugin-platform-h5: 4.0.7 => 4.0.7
      @tarojs/plugin-platform-harmony-hybrid: 4.0.7 => 4.0.7
      @tarojs/plugin-platform-jd: 4.0.7 => 4.0.7
      @tarojs/plugin-platform-qq: 4.0.7 => 4.0.7
      @tarojs/plugin-platform-swan: 4.0.7 => 4.0.7
      @tarojs/plugin-platform-tt: 4.0.7 => 4.0.7
      @tarojs/plugin-platform-weapp: 4.0.7 => 4.0.7
      @tarojs/react: 4.0.7 => 4.0.7
      @tarojs/runtime: 4.0.7 => 4.0.7
      @tarojs/shared: 4.0.7 => 4.0.7
      @tarojs/taro: 4.0.7 => 4.0.7
      @tarojs/taro-loader: 4.0.7 => 4.0.7
      @tarojs/webpack5-runner: 4.0.7 => 4.0.7
      babel-preset-taro: 4.0.7 => 4.0.7
      eslint-config-taro: 4.0.7 => 4.0.7
      react: ^18.0.0 => 18.3.1

补充信息

Button组件能正常触发点击事件

Metadata

Metadata

Assignees

Labels

F-reactFramework - ReactT-alipayTarget - 编译到支付宝小程序V-4Version - 4.x

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions