请问这个代码的问题在哪里,好像是作用域的问题,具体的不明白

当时惘然 当时惘然 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
window.onload = seek;
function preOrder(node){
array.push(node);
node.firstElementChild?(preOrder(node.firstElementChild)):null;
node.lastElementChild?(preOrder(node.lastElementChild)):null;
}
function inOrder(node){
node.firstElementChild?(preOrder(node.firstElementChild)):null;
array.push(node);
node.lastElementChild?(preOrder(node.lastElementChild)):null;
}
function postOrder(node){
node.firstElementChild?(preOrder(node.firstElementChild)):null;
node.lastElementChild?(preOrder(node.lastElementChild)):null;
array.push(node);
}
function seek(){
var root = document.getElementById("root");
var array = [];
var pre = document.getElementById("preOrder");
var mid = document.getElementById("inOrder");
var post = document.getElementById("postOrder");
pre.onclick = function(){
preOrder(root);
}
mid.onclick = function(){
inOrder(root);
}
post.onclick = function(){
postOrder(root);
}
}
...全文

相关推荐

评论 10
收藏 已收藏
分享
返回顶部
当时惘然
JavaScript 87,984 成员 224,681 内容