<Autocomplete
value={value}
onChange={(event, newValue) => {
setValue(newValue);
}}
inputValue={inputValue}
onInputChange={(event, newInputValue) => {
setInputValue(newInputValue);
}}
id="controllable-states-demo"
options={options}
style={{ width: 300 }}
renderInput={(params) => <TextField {...params} label="Controllable" variant="outlined" />}
/>
请帮帮我,我是打字稿的新手...在下图中,您将看到错误。
谢谢。
正如错误所说,newValue
可以是字符串或空值。它需要一个字符串,因此您应该newValue
在尝试使用它之前测试 的值。
例如:
if newValue !== nil {
setValue(newValue)
}
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句