axios 未捕获的类型错误:some不是函数REACT/ANTDESIGN

wyyhbhjk  于 2023-06-22  发布在  iOS
关注(0)|答案(1)|浏览(181)

我试图解决这个问题几乎一天。我考虑了每一种可能的解决方案,已经寻找了很长时间,但真的不知道哪里出了问题。
我需要使表与Ant Design和初步渲染所有的用户应显示。我正在使用React / TypeScript、Axios和Zustand进行状态管理。问题是,一切都工作得很完美,我取了数据,它工作,但后来不知从哪里我得到了错误"uncaught TypeError: rawData.some is not a function".
my Store.tsx

我的表组件:

import {Table} from "antd";
import userStore from "./Store/Store";
import { useEffect} from "react";

const usersTable = () => {
  const { users, loading, error, fetchUsers} = userStore();

  useEffect(()=>{
    fetchUsers();
 }, [])

  const columns = [
    {
      title: 'Name',
      dataIndex: 'name',
      key: 'name',
    },
    {
      title: 'Email',
      dataIndex: 'email',
      key: 'email',
    },
    {
      title: 'Gender',
      dataIndex: 'gender',
      key: 'gender',
    },
    {
      title: 'Street',
      dataIndex: ['address', 'street'],
      key: 'street',
    },
    {
      title: 'City',
      dataIndex: ['address', 'city'],
      key: 'city',
    },
    {
      title: 'Phone',
      dataIndex: 'phone',
      key: 'phone',
    },
  ];

if (loading) {
    return <div>Loading...</div>;
  }

  if (error) {
    return <div>Error: {error.message}</div>;
  }
  
  return (
    <>
    <Table dataSource={users} columns={columns}/>
    </>
  )
}

export default usersTable

我检查了代码中的所有内容,当然我没有明确定义rawData

lkaoscv7

lkaoscv71#

我曾经遇到过类似的问题,这是由于以下原因。这可能是因为您试图查询表中不存在的属性。请检查您的查询和表中的相应属性。

相关问题