阿肥有远端抓资料
const [dataList, setData] = useState([]);
useEffect(() => {
const fetchData1 = async () => {
const response = await
fetch('http://localhost/abc/def'){
method: "POST",
}
);
var data = await response.json();
setData(data);
};
然后路由
return (
<BrowserRouter>
<Routes>
<Route path={dataList.aaa} element={<Home />} />
</Routes>
</BrowserRouter>
)
理论上我连上前端网站 /aaa
应该要有资料
但是全红画面
Cannot read properties of undefined (reading 'data')
阿肥哪里弄错惹