javascript - 节点 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>
我得到了我想要的新页面,而无需重新加载。
那么,这里发生了什么?我有点困惑。
解决方案
推荐阅读
- ruby - 如何使 ruby ocra 与多个源文件一起工作?
- java - 如何修复以下代码中的“浮点数无法转换为浮点数 []”错误?
- c++ - #include .h 文件时编译失败,但 #include .cpp 文件时编译成功
- python-2.7 - 使用Python向二叉树中的缺失节点添加值
- python - 获取变量 pandas 可接受值的函数
- python - 如何从具有特定属性的字典中打印键列表
- sql - SQL 协助 - STUFF 和 XML 路径连接数据
- bash - 为什么我要创建一个别名来创建一个函数?
- java - 如何在 Hazelcast 配置中以编程方式减少 RAM?
- hadoop - 无法启动 Yarn 进程