首页 > 解决方案 > Material UI AutoComplete 设置值为 0

问题描述

我一直在这个错误上停留了一段时间,不知道发生了什么,如果你有第二个,请你帮忙。谢谢你。

问题:

我已经在codesandbox上复制了这个问题,请参阅下面的链接 https://codesandbox.io/s/material-not-working-her-weg6e?file=/src/App.js

标签: reactjsmaterial-uireact-hook-form

解决方案


你的代码沙箱里有很多与问题无关的不需要的代码。我已经把它清理干净了。

  1. 初始化状态 - const [inputValue, setInputValue] = React.useState("");

  2. OnChange,更新状态

    onChange={(e, data) => {
         setInputValue(data.year);
       }}
    

这是一个记录所选分辨率代码 代码沙箱值的工作代码


推荐阅读