V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
oppddd
V2EX  ›  React

antd/procomponents 如何声明新创建的 valuetype 类型?

  •  
  •   oppddd · Mar 17, 2023 · 1664 views
    This topic created in 1142 days ago, the information mentioned may be changed or developed.
    const DesRender = ({ columns }: { columns: XFormColumn[] }) => {
      const list = columns.map((column) => {
        const key = Array.isArray(column.dataIndex) ? column.dataIndex.join(',') : column.dataIndex
        const isEnumPick = column.valueType === 'enum'
        const valueType = column.valueType === 'enum' ? 'text' : column.valueType
        if (isEnumPick) {
          return <ProDescriptions.Item key={key}
            label={column.title}
            dataIndex={column.dataIndex}
            // TODO:valueType = enum 这里 ts 不安全了,enum 是我自定义的 valuetype;如何告知 ts 我的类型
            valueType={column.valueType as 'text'}
            fieldProps={column.fieldProps}
          >
          </ProDescriptions.Item>
        }
        return <ProDescriptions.Item
        key={key}
        label={column.title}
        dataIndex={column.dataIndex}
        valueType={valueType}
        >
        </ProDescriptions.Item>
      })
      return list
    }
    
    No Comments Yet
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   2458 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 29ms · UTC 15:20 · PVG 23:20 · LAX 08:20 · JFK 11:20
    ♥ Do have faith in what you're doing.