Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

search-result spec #2

Closed
JIACHENG9 opened this issue Jun 22, 2019 · 0 comments
Closed

search-result spec #2

JIACHENG9 opened this issue Jun 22, 2019 · 0 comments

Comments

@JIACHENG9
Copy link
Contributor

image

const  obj  = useSearchResult(config);

config:

{
   search: (payload: Store) => (Promise<SearchResponseData> | SearchResponseData); // 发送请求,返回值必须为 SearchResponseData
   defaultPageSize?: number; // 默认的 pageSize,默认为 10
   defaultCurrentPage?: number; // 默认的当前页,默认为 1
   firstAutoSearch?: boolean; // 第一次默认请求,默认为 true
}

responseData

{
  list: object[];      // 列表
  total?: number;  // 总数 
}

obj

{
  Form, // antd form 组件
  Table, // antd Table 组件
  loading, // 是否在请求中
  requestData, // 请求参数
  setRequestData,   // 设置请求参数,比如用于自定义的一些请求 data 处理
  responseData, // 返回数据
  form, // antd form 实例
}

其中 Form.Item 有属性:

<Form.Item
  label="Username"
  name="username"
  rules={[{ required: true, message: 'Please input your username!' }]}
>
  <Input placeholder="Username" />
</Form.Item>
  • Input 为 antd 组件,value 跟 onChange 不用用户处理
  • rules 为 antd form rules
  • name 为 values key,跟 antd3 中使用 getFieldDecorator(name) 相同
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant