export default function Address(props: { onChange?: (value: string) => void }) { const { onChange, ...rest } = props; const [area, setArea] = useState<Array>(); const handleOnChange = (value: string) => { if (onChange) { onChange(value); } }; return ( <Input addonBefore={ <Cascader style={{ width: 'auto', textAlign: 'left' }} options={dataAll} allowClear placeholder='请选择省市区/县' onChange={(value) => setArea(value as Array)} /> } onChange={(e) => handleOnChange(e.target.value)} {...rest} /> ); }

TypeScript 类型转换:将 any 转换为具体类型 - Address 组件示例

原文地址: https://www.cveoy.top/t/topic/lHSk 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录