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

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

Closed
haoyinag opened this issue Aug 5, 2020 · 2 comments
Closed

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

haoyinag opened this issue Aug 5, 2020 · 2 comments

Comments

@haoyinag
Copy link

haoyinag commented Aug 5, 2020

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才都正常了,具体原因不知,估计是和打包插件有冲突

@haoyinag haoyinag changed the title pro-table的columns的title不支持()=>ReactNode 🐛[BUG] pro-table的columns的title不支持()=>ReactNode Aug 6, 2020
@chenshuai2144
Copy link
Contributor

title不支持()=>ReactNode

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

@haoyinag
Copy link
Author

haoyinag commented Aug 7, 2020 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants