2019-10-14培训管理---考试管理部分注意事项

2019-10-14  本文已影响0人  菩灵
建立连接:
@connect(({dictionary}) => ({dictionary}))

引入option值的列表
const { dictionary:{dictTypeList,dictTypeOtherList}, } = this.props

<FormItem label="检查类型">
        {getFieldDecorator('patrolCheckType', {})(
         <Select placeholder="请选择检查类型" style={{ width: '100%' }} allowClear>
           {dictTypeOtherList.map(item => (
             <Option value={item.value} key={item.value}>
                {item.name}
            </Option>
             ))}
        </Select>
      )}
 </FormItem>

由此可知:dictTypeOtherList是一个数组,里面的每一个对象具有value和name属性

  componentDidMount() {
    const { dispatch } = this.props;

    // 获取题库列表
    dispatch({
      type: 'questionBank/fetch',
    });

    // 获取题库分类列表
    dispatch({
      type:'questionBank/fetchQuestionClassifyList'
    })
  }

    questionClassifyObj:{
      records:[]
    }, // 题库分类返回数据

    { questionClassifyObj && questionClassifyObj.records && questionClassifyObj.records.map((item) => (
    <Option value={item.questionBankClassificationId} key={item.questionBankClassificationId}>{item.classificationName}</Option>)) }
行不通:不知道这个id是哪来的
<Table columns={columns} dataSource={data} rowKey="id" />
rowKey : record => record.dataIndex,
或者
rowKey : (record,index)=> index
或者:
rowKey={(r,i)=>(i)}
解决:
<Table style={{ marginTop: 20 }} columns={clientColumns} dataSource={logItems} rowKey={(record, index) => index} pagination={false} bordered scroll={{ x: true }} />

Object.keys()方法使用

在实际开发中,我们有时需要知道对象的所有属性,原生js给我们提供了一个很好的方法:Object.keys(),该方法返回一个数组
传入对象,返回属性名
var obj = {'a':'123','b':'345'};
console.log(Object.keys(obj)); //['a','b']

var obj1 = { 100: "a", 2: "b", 7: "c"};
console.log(Object.keys(obj1)); // console: ["2", "7", "100"]

var obj2 = Object.create({}, { getFoo : { value : function () { return this.foo } } });
obj2.foo = 1;
console.log(Object.keys(obj2)); // console: ["foo"]

传入字符串,返回索引
var str = 'ab1234';
console.log(Object.keys(obj)); //[0,1,2,3,4,5]

构造函数 返回空数组或者属性名
function Pasta(name, age, gender) {
this.name = name;
this.age = age;
this.gender = gender;
this.toString = function () {
return (this.name + ", " + this.age + ", " + this.gender);
}
}

console.log(Object.keys(Pasta)); //console: []

var spaghetti = new Pasta("Tom", 20, "male");
console.log(Object.keys(spaghetti)); //console: ["name", "age", "gender", "toString"]

数组 返回索引
var arr = ["a", "b", "c"];
console.log(Object.keys(arr)); // console: ["0", "1", "2"]
————————————————
原文链接:https://blog.csdn.net/u014035151/article/details/53135610

defaultValue和initialValue不能同时使用

找找看,其他被getFieldDecorator包裹的组件没有有设置defaultValue.包括Select等。有的话都改为initialValue

Valid Accept Types:

For CSV files (.csv), use:

<input type="file" accept=".csv" />

For Excel Files 2003-2007 (.xls), use:

<input type="file" accept="application/vnd.ms-excel" />

For Excel Files 2010 (.xlsx), use:

<input type="file" accept="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" />

For Text Files (.txt) use:

<input type="file" accept="text/plain" />

For Image Files (.png/.jpg/etc), use:

<input type="file" accept="image/*" />

For HTML Files (.htm,.html), use:

<input type="file" accept="text/html" />

For Video Files (.avi, .mpg, .mpeg, .mp4), use:

<input type="file" accept="video/*" />

For Audio Files (.mp3, .wav, etc), use:

<input type="file" accept="audio/*" />

For PDF Files, use:

<input type="file" accept=".pdf" /> 

DEMO:
http://jsfiddle.net/dirtyd77/LzLcZ/144/

上一篇 下一篇

猜你喜欢

热点阅读