import React, { useState } from 'react'; import { Select, Space } from 'antd'; const cityData = { Zhejiang: ['Hangzhou', 'Ningbo', 'Wenzhou'], Jiangsu: ['Nanjing', 'Suzhou', 'Zhenjiang'], }; type CityName = keyof typeof cityData; const provinceData: CityName[] = ['Zhejiang', 'Jiangsu']; const App: React.FC = () => { const [cities, setCities] = useState(cityData[provinceData[0] as CityName]); const [secondCity, setSecondCity] = useState(cityData[provinceData[0]][0] as CityName); const handleProvinceChange = (value: CityName) => { setCities(cityData[value]); setSecondCity(cityData[value][0] as CityName); }; const onSecondCityChange = (value: CityName) => { setSecondCity(value); }; return ( ({ label: city, value: city }))} /> ); }; export default App;