首页 > 解决方案 > 由于空引用框架7,模板无法加载

问题描述

我的页面无法加载,因为 logutzaal 的 getElementById 返回 null 但它确实在其他页面上工作,只有这个页面有这个问题(其他页面有相同的导航栏,只有页面内容不同)。

说它为空的错误:
说它为空的错误

 <template>
  <div class="page" data-name="light">
    <div class="navbar">
      <div class="navbar-bg"></div>
      <div class="navbar-inner sliding">
        <div class="title" id="logoutDiv">
          Zaal Toevoegen
          <a class="btnLogout" id="logutzaal"
            ><i class="fas fa-sign-out-alt logoutButton"></i
          ></a>
          <script>
            document
              .getElementById("logutzaal")
              .addEventListener("click", function () {
                window.location.href = "../index.html";
              });
          </script>
        </div>
      </div>
    </div>
 <div class="page-content">
<h1>Hello</h1>
</div>
</div>
    </template>

标签: html-framework-7

解决方案


推荐阅读