问题:

$scope.list = [];
$scope.listTree = {};
$scope.dataTree = [];
//获取listTree的数据
$scope.getList = function () {
serviceStruct.getAll({},path).then(function (res) {
$scope.listTree = res.data || res.data.result;
getGroup($scope.listTree);
}).then(function(){
$scope.load = true;
});
}
省略若干
……………………………………………………
list,dataTree数组的数据都是从listTree数据中push;现改变list数据,listTree,dataTree的数据也会被更改,
解决此问题就考虑到slice拷贝,亲测不好使,咱没分析原因,另外一种解决方案如下图:
JSON.parse1,JSON.stringify灵活运用,简单实现了slice拷贝

angular,,以及深度拷贝问题;JSON.parse,JSON.stringify灵活运用

 

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-09-08
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-12-29
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-08-03
  • 2021-08-29
  • 2021-10-01
  • 2022-12-23
相关资源
相似解决方案