react 常用问题总结

//表格列添加判断
{
            title: '选择组织',
            dataIndex: 'myId',
            inputtype: 'select',
            width: 150,
            align: 'center',
            editable: true,
        },
        ...(this.props.role == 3 ? [{
            title: '选择部门',
            dataIndex: 'departmentIds',
            inputtype: 'select',
            width: 150,
            align: 'center',
            editable: true,
        }] : []),
//给某个变量赋值
 setFieldsValue({ [`departmentIds-${record.key}`]: [0] });
//给普通字段赋值
setFieldsValue({ departmentIds: [0] });

 

//行内绑定组件的方式
 errorComponent={() => <Empty image={Empty.PRESENTED_IMAGE_SIMPLE} description={<span>暂无文件</span>} />}

 

//react新增生命周期
static getDerivedStateFromProps(props, state) {
        if (props.pageData.list !== state.fileData) {
            return {
                fileData: props.pageData.list ? props.pageData.list : [],
            };
        }
        return null;
    }

 

posted @ 2020-12-31 15:45  dongxiaolei  阅读(105)  评论(0编辑  收藏  举报