diff --git a/themes/nav/index.js b/themes/nav/index.js index 3e7e3db0..92895ea6 100755 --- a/themes/nav/index.js +++ b/themes/nav/index.js @@ -72,63 +72,65 @@ const LayoutBase = (props) => { return ( - + + // console.log("load"); + // 在页面载入时,调用一次updateHref函数,并将isLoaded设为true + window.addEventListener("load", function() { + console.log("window load"); + updateHref(); + }); + + // 在页面大小改变时,调用一次updateHref函数 + // window.addEventListener("resize", updateHref); + + // 开始监听body元素的变化,配置选项为子节点变化和子孙节点变化 + observer.observe(document.body, {childList: true, subtree: true}); + + // 在每个变化记录之后,检查isLoaded是否为true,如果是,则执行updateHref函数 + // observer.disconnect(); // 停止监听body元素的变化 + // observer.observe(document.body, {childList: true, subtree: true}); // 重新开始监听body元素的变化 + +