import { api } from "@nice/client" import { apiClient } from "@web/src/utils" import { Button, Tag } from "antd" import { useEffect, useMemo, useState } from "react" function HomePage() { const { data: staffData } = api.staff.findMany.useQuery({ take: 10 }) // 建议为不同的查询结果使用不同的变量名 const { data: goodsData } = api.goods.hello.useQuery({ name: "123" }) const [counter, setCounter] = useState(0) const counterText = useMemo(() => { return `当前计数为:${counter}` }, [counter]) const getData = async () => { // 第一种写法 // const res = await apiClient.get("/goods/hello") // console.log(res) //第二种写法 apiClient.get("/goods/hello") .then(res => { console.log(res) }) } useEffect(() => { getData() }, []) return
{counterText}
{ staffData?.map(i => { return
{i.username}
}) }
{goodsData}
} // export { HomePage } export default HomePage