我有一個返回這個 json 的 api,我想做的是,我只是獲取 json 返回的“名稱”并將其放入文本組件中。我嘗試這樣做,但它返回 null 或完整 json。{ "user": { "_id": "1", "name": "User Name", "email": "[email protected]", } }const [cars, setCars] = useState([]); async function loadCars() { const response = await api.get('me'); setCars(response.data); }
使用 React hooks 對 json 數據進行切片
瀟湘沐
2023-10-20 16:39:01