immutable basis for use

fromJS: deep conversion, all native JS objects are converted to immutable objects


toJS: deep converter converts immutable object native JS objects
the let immutable.fromJS State = ({
name: "Joe Smith",
obj: {
username: "123",
password: 456
},
ARR: [l, 2,3 ,. 4],
ABC: [
{
goodsId:. 1,
goodsName: "123"
}
]
})
the console.log (State);
the console.log (state.toJS ());
* * /

 

 

/*
const list = immutable.List([1,2,3,4]);

//增
let list1 = list.push(10);
console.log(list1);

// delete change
the let list.splice List2 = (0,1);
the console.log (List2);


//check

// List the immutable object is converted into an array of JS conversion layer can toArray
the let List.toArray ARR = ();
the console.log (ARR);

 

const list = immutable.List([1,2,3,4]);
const list1 = immutable.List(["a","b","c"]);
//合并
const list2 = list.concat(list1);
console.log(list2);
* */

 

 

 

 

 

 


/*
const map = immutable.Map({
a:1,
b:2,
obj:{
name:"zhangsan"
}
})

the console.log (map)
// converts the map object to the native target single-level conversion JS
console.log (map.toObject ());

console.log(map) // Map{a:1,b:2}


//增
let map1 = map.set("c",3);
console.log(map1)

//增
let map1 = map.setIn(["obj","name"],"张三");
console.log(JSON.stringify(map1))


//删
let map1 = map.delete("a")
console.log(map1)

let map1 = map.deleteIn(["obj","name"])
console.log(JSON.stringify(map1))

 

//改
let map1 = map.update("a",(params)=> params = 10)
console.log(map1)

//改
let map1 = map.updateIn(["obj","name"],(name)=>name="李四")
console.log(JSON.stringify(map1))


//查
let map1 = map.get("a");
let map2 = map.getIn(["obj","name"]);
console.log(map1,map2)
*/

Guess you like

Origin www.cnblogs.com/PeiGaGa/p/11032760.html