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;
    }

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章