我是 React 新手,尝试使用 axios 获取 api 数据时出现编译失败错误。
Axios.js:
import axios from 'axios'
const instance = axios.create({
baseURL: 'http://localhost:8001'
})
export default instance;
Cards.js:
import React, { useState, useEffect } from 'react'
import "./Cards.css"
import TinderCard from "react-tinder-card"
import axios from './Axios'
function Cards() {
const [people, setPeople] = useState([]);
useEffect(() => {
async function fetchData () {
const req = await axios.get("/tinder/cards")
setPeople(req.data);
}
fetchData()
}, [])
const swiped = (direction, nameToDelete) => {
console.log("removing: " + nameToDelete);
// setLastDirection(direction)
}
const outOfFrame = (name) => {
console.log(name + "left the screen!");
}
return (
<div className="Cards">
<div className="Cards__cardContainer">
{people.map((person) => (
<TinderCard
className="swipe"
key={person.name}
preventSwipe={["up", "down"]}
onSwipe={(dir) => swiped(dir, person.name)}
onCardLeftScreen={() => outOfFrame(person.name)}
>
<div
style={{ backgroundImage: `url(${person.url})`}}
className="card"
>
<h3>{person.name}</h3>
</div>
</TinderCard>
))}
</div>
</div>
)
}
export default Cards;
错误:
<块引用>编译失败。
./src/Axios.js 语法错误:C:\Users\suhai\Documents\evP\Hinder\h\highlancer\src\Axios.js: 意外令牌 (1:18)
1 |从 axios 导入 axios
| ^
2 |
3 | const 实例 = axios.create({
4 | baseURL: 'http://localhost:8001'
答案 0 :(得分:1)
您的导入似乎已关闭,请试一试。
csv_pandas.dtypes
dateofbirth datetime64[ns]
lastupdates datetime64[ns]
dateofjoin datetime64[ns]
dateofresign datetime64[ns]
dtype: object