나는이 오류가 내가 사용 jstree lib 디렉토리 트리를 구축하기 위해 노력하고있어 그잡히지 않음 RangeError : 최대 호출 스택 크기를 초과했습니다. jstree
Uncaught RangeError: Maximum call stack size exceeded
해결하는 방법을 모르겠어요. 데이터는 두 가지 다른 http 호출에서 가져옵니다. 나는이처럼 내 초기 데이터를 받고 있어요 :
$scope.treeFolders = [];
$scope.treeFilters = [];
$scope.tree = [];
var folders = function() {
$http.get("folders.json")
.success(function (res) {
angular.forEach(res, function(parent){
// console.log(parent)
if(!("parent" in parent)){
parent.parent = "#"
}
})
$scope.treeFolders = res
console.log($scope.treeFolders)
});
};
folders();
var filters = function(){
$http.get("child.json")
.success(function (res) {
angular.forEach(res, function(obj){
if(!("parent" in obj)){
// console.log(obj.folderId)
obj.parent = obj.folderId;
}
// console.log(obj)
});
$scope.treeFilters = res;
console.log($scope.treeFilters)
});
};
filters();
을 console.log가 배열을 반환, 이제 모든 것을하는 것은 좋다. 그럼 난 두 배열
$scope.load = function(){
// method 1
$scope.tree = $scope.treeFolders.concat($scope.treeFilters);
console.log(JSON.stringify($scope.tree))
// method 2
// $scope.treeFolders.forEach(function(item){
// $scope.tree.push(item)
// })
// $scope.treeFilters.forEach(function(item){
// $scope.tree.push(item)
// })
// console.log(JSON.stringify($scope.tree))
}
그래서 당신이 볼 수있는 슈퍼 배열 하나에, 나뿐만 아니라 도움을 두 가지 방법으로 하나 개의 배열, 두 작품을 얻기 위해 노력 병합 기능로드를 사용하고 있는데 나는이 배열을 얻을
로직 jstree의 문서에 의한[{
"id":1,
"userId":1,
"createdDt":"2016-06-27T13:05:03.000+0000",
"text":"folder",
"parent":"#"
},{
"id":2,
"parent":1,
"userId":1,
"createdDt":"2016-06-27T13:26:45.000+0000",
"text":"child folder"
},{
"id":2,
"folderId":2,
"folder":{"id":2,"text":"child folder"},
"body":"empty",
"user":{"id":1,"name":"User 1"},
"userId":1,
"createdDt":"2016-06-27T13:05:47.000+0000",
"text":"filter 1",
"parent":2
},{
"id":3,
"folderId":2,
"folder":{"id":2,"text":"child folder"},
"body":"nothing",
"user":{"id":1,"name":"User 1"},
"userId":1,"createdDt":"2016-06-27T13:00:00.000+0000",
"text":"filter 4",
"parent":2
}]
추적, 내 나무
* Folder (root)
---- * Child Folder (parent)
---- * Filter 1 (Child)
---- * Filter 4 (Child)
과 같아야하지만,이 대신에 어디 선가 너무 많이 반복되는 오류가 발생합니다. 누군가 내 실수를 찾도록 도와 줄 수 있습니까? 미리 감사드립니다. Plunker이 붙어 있습니다.
오,이 문제가있어, 설명 주셔서 감사합니다 ..하지만 내가 그것을 바꿀 것입니다, 그것은 DB 구조를 깰. 예를 들어 ID가 5 인 필터가 있고 ID가 5 인 폴더가 있고 필터 ID를 6으로 변경 한 경우이 필터를 삭제하려고합니다. 이 필터를 삭제하기 위해 API에 요청을 보내지 만 API ID가 6이고 잘못된 필터를 삭제하는 것으로 보입니다. 어떻게해야합니까? – antonyboom
제가 따르기는 어렵지만 API 나 데이터 소스와 다른 문제 인 것 같습니다. jsTree의 경우 각 노드에서 상위 속성을 정의하는 경우 각 항목에 대해 고유 한 ID가 있어야하며 상위 - 하위 관계에 대한 순환 참조는 피해야합니다. – Adam
필터에 사용할 각 항목의 속성을 지정하는 것이 도움이 되나요? [JSON 소스 데이터] (https://www.jstree.com/docs/json/)에서 "li_attr"및 "a_attr"을 확인하십시오. – Adam