首页 > 解决方案 > 节点 js Web 应用程序中的 class="route-link" 和 class="fas fa-link" 行为混淆

问题描述

我正在用 node js 构建一个简单的 web 应用程序。我是使用 node js 构建 Web 应用程序的新手,但对 Web 应用程序开发本身并不陌生。我已将此 Web 应用程序插入到我已经构建和部署的 api 服务器,并在其间插入了身份验证服务器。

所以,我有一个登录按钮。我还有一个按钮,显示登录的用户配置文件。都好。

我为一组新按钮添加了一个新 div。

    <div class="page" id="content-apiservicedemo">
      <div class="container">
      <hr>
      <p>here comes the simple api button</p>
      <button id="btn-call-api" disabled="true" onclick="callApi()">Call Api</button>

      <!-- Add a container to hold the response from the call -->
      <pre id="api-call-result"></pre> 
      </div>         
    </div> 

我使用了一个链接来显示该部分。

          <a href="/apiservicedemo">
            <i class="fas fa-link"></i> here
          </a> 

然后,我发现,这个链接,不断地重新加载整个页面。我的意思是说,当我点击它时,它会触发一次页面重新加载。

为了添加额外的上下文,设计了当前的 nod js 应用程序(我相信这是基于 node js 的单页应用程序中的标准东西),它只是根据单击的路径隐藏和显示特定的 div。

我以这种方式使用了这个链接。(这是在此模板/教程应用程序中编写家庭和个人资料详细信息的当前链接的方式)

<a href="/apiservicedemo" class="route-link">here 2</a>

我得到了我想要的新页面,而无需重新加载。

那么,这里发生了什么?我有点困惑。

标签: javascriptcssnode.js

解决方案


推荐阅读