Advertisement
Guest User

Untitled

a guest
Apr 20th, 2017
153
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.57 KB | None | 0 0
  1. 查看那Immutable.js的api,发现可以使用get方法获取某个属性值,在于React结合时,我修改了state,使其变为:
  2. this.state = Immutable.fromJS({
  3. userName: '',
  4. password: ''
  5. });
  6.  
  7. 而我在render方法里的解构依然生效, amazing!!!!!!!
  8.   const { userName, password } = this.state;
  9.  
  10. 尝试了使用map方法,会返回value值:
  11. this.state.map(x => console.log(x));
  12.  
  13. 使用for of循环可以获取到key、value,蛮棒的的
  14. for(let [key, value] of this.state.entries()) {
  15.   console.log(key + ':' + value);
  16. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement