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

input 标签不受控 #12111

Closed
gyf30827 opened this issue Jul 26, 2022 · 3 comments
Closed

input 标签不受控 #12111

gyf30827 opened this issue Jul 26, 2022 · 3 comments
Labels
F-react Framework - React T-h5 Target - 编译到 H5 V-3 Version - 3.x
Milestone

Comments

@gyf30827
Copy link

gyf30827 commented Jul 26, 2022

相关平台

H5

复现仓库

https://github.com/gyf30827/taro-demo
浏览器版本: chrome ,版本 103.0.5060.134(正式版本) (x86_64)
使用框架: React

复现步骤

1.启动demo项目后
2.在输入框内输入超过3个字符

期望结果

只显示3个字符

实际结果

输入几个显示几个

环境信息

👽 Taro v3.4.14


  Taro CLI 3.4.14 environment info:
    System:
      OS: macOS 11.5.1
      Shell: 5.8 - /bin/zsh
    Binaries:
      Node: 16.15.1 - ~/.nvm/versions/node/v16.15.1/bin/node
      Yarn: 1.22.19 - /usr/local/bin/yarn
      npm: 8.11.0 - ~/.nvm/versions/node/v16.15.1/bin/npm
    npmPackages:
      @tarojs/components: 3.4.14 => 3.4.14 
      @tarojs/mini-runner: 3.4.14 => 3.4.14 
      @tarojs/plugin-framework-react: 3.4.14 => 3.4.14 
      @tarojs/react: 3.4.14 => 3.4.14 
      @tarojs/runtime: 3.4.14 => 3.4.14 
      @tarojs/taro: 3.4.14 => 3.4.14 
      @tarojs/webpack-runner: 3.4.14 => 3.4.14 
      babel-preset-taro: 3.4.14 => 3.4.14 
      eslint-config-taro: 3.4.14 => 3.4.14 
      react: ^17.0.0 => 17.0.2 

demo内受控逻辑代码
image

@taro-bot2 taro-bot2 bot added F-react Framework - React T-h5 Target - 编译到 H5 V-3 Version - 3.x labels Jul 26, 2022
@ZakaryCode ZakaryCode added this to the 3.5.0 milestone Jul 26, 2022
@ZakaryCode
Copy link
Contributor

3.5+ 版本中会在 input 组件内主动修改输入值控制 value,低版本中遇到相同值不受控制情况需要获取 input 组件实例修改 value 值避免控制失效。

在 react 组件中相同的 value 不会触发组件更新,这同样会导致 input 组件失去控制,所以在此情况下也需要手动触发组件更新。

@shinken008
Copy link
Collaborator

貌似在微信小程序也不受控

@bluescurry
Copy link
Contributor

貌似在微信小程序也不受控

可以参考这个临时解决方案:#2642

@ZakaryCode ZakaryCode moved this to Done in H5 Apr 10, 2023
@ZakaryCode ZakaryCode added this to H5 Apr 10, 2023
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
Development

No branches or pull requests

4 participants