react中怎么动态显示colunm

columnsFilter = (mobile) => {
        let columns
        // 16619924200
        // 15242099188
        if (['15242099188'].includes(mobile)) {
            columns = [
                {
                    title: '商品名称',
                    dataIndex: 'productName',
                    key: 'productName',
                },
                {
                    title: '条码',
                    dataIndex: 'barCode',
                    key: 'barCode',
                },
                {
                    title: '型号',
                    dataIndex: 'type',
                    key: 'type',
                },
                {
                    title: '品牌',
                    dataIndex: 'brandName',
                    key: 'brandName',
                },
                {
                    title: '单位',
                    dataIndex: 'unitOne',
                    key: 'unitOne',
                },
                {
                    title: '数量',
                    dataIndex: 'quantity',
                    key: 'quantity',
                },
                {
                    title: '操作',
                    dataIndex: 'operation',
                    key: 'operation',
                    // [' 15242099188'].includes(this.state.mobile) ? 
                    render: (text, item) => (
                        <>
                            {
                                // console.log(this.state.mobile, 'this.state.mobile')
                                // ['15242099188'].includes(this.state.mobile) ? 
                                <a className="delBtn" onClick={() => this.handleDelArchives(item)} >删除</a>
                            }
                        </>
                    )
                },
            ]
        } else {
            columns = [
                {
                    title: '商品名称',
                    dataIndex: 'productName',
                    key: 'productName',
                },
                {
                    title: '条码',
                    dataIndex: 'barCode',
                    key: 'barCode',
                },
                {
                    title: '型号',
                    dataIndex: 'type',
                    key: 'type',
                },
                {
                    title: '品牌',
                    dataIndex: 'brandName',
                    key: 'brandName',
                },
                {
                    title: '单位',
                    dataIndex: 'unitOne',
                    key: 'unitOne',
                },
                {
                    title: '数量',
                    dataIndex: 'quantity',
                    key: 'quantity',
                }

            ]
        }
        return columns
    }

 <Table
                                rowKey="id"
                                columns={this.columnsFilter(mobile)}
                                dataSource={getDetail ? getDetail.goodsList : []}
                                bordered
                                pagination={false}
                                rowSelection={rowSelection}
                            />
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值