ant-design / pro-components

🏆 Use Ant Design like a Pro!
https://pro-components.antdigital.dev
MIT License
4.24k stars 1.35k forks source link

🐛[BUG] pro-table的columns的title不支持()=>ReactNode #101

Closed haoyinag closed 4 years ago

haoyinag commented 4 years ago

pro-table的columns的title不支持()=>ReactNode,开发环境是正常的,打包编译之后线上不行,根本不进入函数

💻 复现代码

原函数

      // 送达/取货/下单时间  history:实际送达时间
      // title: (_) => {
      //   console.log(_);

      //   let arrTimes: any[] = [];
      //   deliveryTimes.map((time) => arrTimes.push(time));
      //   // console.log("送达/取货/下单时间 ", arrTimes);

      //   const index = arrTimes.findIndex(
      //     (item) => item.value === "actualDeliveredAt"
      //   );
      //   if (type !== "history" && index !== -1) {
      //     arrTimes.splice(index, 1);
      //   }

      //   if (type === "history" && index === -1) {
      //     arrTimes.push({
      //       label: "实际送达时间",
      //       value: "actualDeliveredAt",
      //     });
      //   }
      //   // console.log("送达/取货/下单时间 ", arrTimes);
      //   return (
      //     <Select
      //       defaultValue={filterPrefixTypes?.deliveryTimes}
      //       onSelect={(val) => onFilterPrefixSelect(val, "deliveryTimes")}
      //     >
      //       {arrTimes.map((item: any) => (
      //         <Option key={item.value} value={item.value}>
      //           <Tooltip title={item.label}>
      //             <span>{item.label}</span>
      //           </Tooltip>
      //         </Option>
      //       ))}
      //     </Select>
      //   );
      // },

修复后,也不能说修复,只是绕过了

searchSelectColumns = produce(
    searchSelectColumns,
    (draftSearchSelectColumns) => {
      let arrTimes: any[] = [];
      deliveryTimes.map((time) => arrTimes.push(time)); 

      const index = arrTimes.findIndex(
        (item) => item.value === "actualDeliveredAt"
      );
      if (type !== "history" && index !== -1) {
        arrTimes.splice(index, 1);
      }

      if (type === "history" && index === -1) {
        arrTimes.push({
          label: "实际送达时间",
          value: "actualDeliveredAt",
        });
      }
      console.log("送达/取货/下单时间 ", arrTimes);
      draftSearchSelectColumns[2].title = (
        <Select
          defaultValue={filterPrefixTypes?.deliveryTimes}
          onSelect={(val) => onFilterPrefixSelect(val, "deliveryTimes")}
        >
          {arrTimes.map((item: any) => (
            <Option key={item.value} value={item.value}>
              <Tooltip title={item.label}>
                <span>{item.label}</span>
              </Tooltip>
            </Option>
          ))}
        </Select>
      );
    }
  );

© 版本信息

"@amap/amap-jsapi-types": "^0.0.4",
    "@ant-design/pro-layout": "^5.0.9",
    "@ant-design/pro-table": "^2.2.7",
    "@types/jest": "^25.2.1",
    "@types/react": "^16.9.34",
    "@umijs/hooks": "^1.9.2",
    "@umijs/preset-react": "1.x",
    "@umijs/test": "^3.1.1",
    "antd-dayjs-webpack-plugin": "^1.0.0",
    "cross-env": "^7.0.2",
    "html2canvas": "^1.0.0-rc.5",
    "lint-staged": "^10.0.7",
    "postcss-px-to-viewport": "^1.1.1",
    "prettier": "^2.0.5",
    "react": "^16.12.0",
    "react-amap": "^1.2.8",
    "react-dom": "^16.12.0",
    "stylus": "^0.54.7",
    "stylus-loader": "^3.0.2",
    "ts-md5": "^1.2.7",
    "typescript": "^3.8.3",
    "umi": "^3.1.1",
    "yorkie": "^2.0.0"

这样修改之后,开发环境和online才都正常了,具体原因不知,估计是和打包插件有冲突

chenshuai2144 commented 4 years ago

title不支持()=>ReactNode

这个是在比较新的版本的中支持的,你不是把 lock 之类的文件上传到打平台了

haoyinag commented 4 years ago

可能是,我验证一下

获取 Outlook for iOShttps://aka.ms/o0ukef


发件人: 陈帅 notifications@github.com 发送时间: Thursday, August 6, 2020 2:09:37 PM 收件人: ant-design/pro-components pro-components@noreply.github.com 抄送: ChenHaoYin haoyinag0@hotmail.com; Author author@noreply.github.com 主题: Re: [ant-design/pro-components] 🐛[BUG] pro-table的columns的title不支持()=>ReactNode (#101)

title不支持()=>ReactNode

这个是在比较新的版本的中支持的,你不是把 lock 之类的文件上传到打平台了

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://github.com/ant-design/pro-components/issues/101#issuecomment-669723087, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AFZYZ642MQ3FNFSU7LJ26OTR7JCKDANCNFSM4PVFL7YQ.