VUE前端从后台请求过来的数据进行转换数据结构操作
我就废话不多说了,大家还是直接看代码吧`
letlabel(){
let_this=this;
let_offset=(_this.pagination.currentPage-1)*_this.pagination.pageSize
letparams={
offset:_offset,//分页偏移量
limit:_limit,//分页查询数量
}
labelView(",params).then(res=>{
_this.list=res.data.data
_this.pagination.total=res.data.pagination.total;
//转换数据
lettreeDataArray=newArray();
constelement=_this.list
letobj={
name:"",
isExpand:true,
children:newArray()
}
treeDataArray.push(obj);
for(letdd1=0;dd1<_this.list.length;dd1++){
constelement=_this.list[dd];
letobj1={
root:true,
isExpand:true,
name:element['model'],
children:newArray()
}
obj.children.push(obj1);
for(letdd2=0;dd2
补充知识:Vue中使用Map数据结构的坑,直接set无法触发双向数据绑定(解决方案)
1.因为想贯彻es6的使用,在项目中多多使用es6的特性,结果Map的set方法去更新数据,视图无法同步,
故而使用重新设置的方式达到目的,类似
letobj=Object.assign({},{})
或者
letarr=[].concat['a']
letno=server_no.toString()
letis_check=this.collated_data.get(no).is_check
this.collated_data.get(no).is_check=!is_check
//使用Map数据结构只能这样更新
this.collated_data=newMap(this.collated_data)
重新赋值,而不是更改引用。
以上这篇VUE前端从后台请求过来的数据进行转换数据结构操作就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持毛票票。
热门推荐
1 训练狗狗憋尿
2 狗狗追踪训练
3 狗狗训练要多少钱
5 深圳狗狗训练
6 训练狗狗唤回
7 狗狗叫怎么训练
8 狗狗训练班
10 狗狗社会化训练
11 狗狗叫回训练
12 广州狗狗训练学校
13 狗狗训练躺下
14 狗狗随行训练
15 训练狗狗巡回
16 狗狗要怎么训练
17 狗狗喂食训练
18 训练狗狗躺下