【问题标题】:how to use jquery file only once in angularjs如何在angularjs中只使用一次jquery文件
【发布时间】:2017-12-31 10:58:54
【问题描述】:

如何在我的场景中只调用一次 jquery 文件

我在 Mean Technology 工作

我有一个 UI(工作 Html 页面)。在那个 UI 中有页眉、页脚、侧边栏 这些页眉、页脚、侧边栏来自单独的 UI。我已经结合在我的 Every html 中使用。

这是组合所有 html 页面并在我的每个页面中使用它的方式。

<div id="sidebar" class="sidebar responsive ace-save-state" ng-controller="SlideController" ng-include="'slidebar.html'">

在我的侧栏.html 中我使用了这个 jquery

在我的 header.html 中也是这样

  <script src="/assets/js/jquery-2.1.4.min.js"></script>

在 originalUI.html(工作 Html 页面)中我也使用过

<script src="/assets/js/jquery-2.1.4.min.js"></script> 

如果我运行我的 UI。这个 jquery 将加载 3 次。所以一些功能在那个时候不起作用它会返回

jquery-2.1.4.min.js Failed to load resource: the server responded with a status of 404 (Not Found)

如果我在标题和侧边栏中删除了该 jquery。不起作用的功能将起作用。

我不知道为什么。谁能告诉我如何解决这个问题

【问题讨论】:

  • 从错误信息中可以看出,jquery文件的引用路径错误。而且您只需要添加对一个 HTML 的引用。 .即 indext.html 或主 html 文件
  • @Ved 在那个路径中只有我保留了文件。如果我在我的标题和侧边栏中删除了那个 jquery。不起作用的功能将起作用。但侧边栏不起作用
  • 您不需要多个参考。只需将其包含在主 html 文件中
  • main html 是指工作 html?
  • 你的根 html 文件。

标签: jquery angularjs mean


【解决方案1】:

您必须将 jquery 引用添加到应用程序的起始 HTML 文件(例如:index.html、layout.html),而不是将其添加到每个文件中

【讨论】:

  • 嗨 user1594,我试过这样。但它不工作。它会影响我的侧边栏功能
猜你喜欢
  • 1970-01-01
  • 2013-10-08
  • 2021-03-11
  • 1970-01-01
  • 1970-01-01
  • 2023-03-15
  • 2013-07-22
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多