Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 查看那Immutable.js的api,发现可以使用get方法获取某个属性值,在于React结合时,我修改了state,使其变为:
- this.state = Immutable.fromJS({
- userName: '',
- password: ''
- });
- 而我在render方法里的解构依然生效, amazing!!!!!!!
- const { userName, password } = this.state;
- 尝试了使用map方法,会返回value值:
- this.state.map(x => console.log(x));
- 使用for of循环可以获取到key、value,蛮棒的的
- for(let [key, value] of this.state.entries()) {
- console.log(key + ':' + value);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement