pro-table icon indicating copy to clipboard operation
pro-table copied to clipboard

🐛[BUG]初始化时执行 submit 无效

Open baranwang opened this issue 4 years ago • 4 comments

🐛 bug 描述

初始化时执行 submit 无效

💻 复现代码 [提供可复现的代码,仓库,或线上示例]

import React, { useRef, useEffect } from "react";
import { request, useLocation } from 'umi';
import ProTable from '@ant-design/pro-table';
import { FormInstance } from 'antd/es/form';

export default () => {
  const formRef = useRef<FormInstance>();
  const location: any = useLocation();
  const { user_id } = location.query;

  useEffect(() => {
    if (!user_id || !formRef.current) return;
    formRef.current.setFieldsValue({ user_id });
    formRef.current.submit();
  }, [user_id]);

  return (
    <ProTable<User>
      formRef={formRef}
      request={async params => {
        const { total, data } = await request("user/", {
          params: {
            ...params,
            limit: params.pageSize,
            page: params.current
          }
        });
        return { data, total };
      }}
      rowKey="id"
      columns={[]}
    ></ProTable>
  );
};

© 版本信息

  • Ant Design Pro 版本: 4.1.0
  • umi 版本: 3.0.18

baranwang avatar Apr 04 '20 09:04 baranwang

你是想做什么,可以 form还没有初始化成功导致的

chenshuai2144 avatar Apr 04 '20 15:04 chenshuai2144

通过获取 url 参数,进行搜索。我看 setFieldsValue 是成功了的, 但是 submit 没有效果

baranwang avatar Apr 04 '20 16:04 baranwang

通过获取 url 参数,进行搜索。我看 setFieldsValue 是成功了的, 但是 submit 没有效果

您好 我们也遇到了这个问题 请问你们有找到解决方法吗?

AlanKnightly avatar Nov 03 '21 09:11 AlanKnightly

@baranwang form 自带了synctourl的,你用自带的呢

chenshuai2144 avatar Nov 14 '21 11:11 chenshuai2144