两者都chrome.bookmarks.getTree返回BookmarkTreeNodeschrome.bookmarks.getRecent数组,但 BookmarkTreeNodes 不一定有属性。在 的情况下,树的顶部节点是文件夹并且没有 URL:urlgetTree

如果使用getTree,则必须使用每个节点的children数组递归遍历树。知道每个 BookmarkTreeNode要么有一个children属性(如果它是一个文件夹)要么有一个url属性(如果它是一个实际的书签)会有所帮助。尝试类似:
chrome.bookmarks.getTree(function(itemTree){
itemTree.forEach(function(item){
processNode(item);
});
});
function processNode(node) {
// recursively process child nodes
if(node.children) {
node.children.forEach(function(child) { processNode(child); });
}
// print leaf nodes URLs to console
if(node.url) { console.log(node.url); }
}