gpt4 book ai didi

javascript - 我应该如何在网页中找到我的脚本

转载 作者:行者123 更新时间:2023-12-03 02:52:45 25 4
gpt4 key购买 nike

我正在使用一些 Web 技术(如 Javascript 和 JQuery)开发 ASP MVC Web 应用程序。

由于我的项目中大量使用脚本,我在代码中这些脚本的正确位置和顺序方面面临很多问题。

事实上,我的浏览器中总是出现错误。

例如,当我按以下顺序在 Head 标记中找到这些脚本时:

<script src="~/Scripts/jquery.validate.min.js"></script>
<script src="~/Scripts/jquery.validate.unobtrusive.min.js"></script>
<script src="~/Scripts/jquery-1.10.2.min.js"></script>
<script src="/template/web/js/jquery-ui.js"></script>

我会收到这些错误,其中提到了 JQuery 定义的问题:

jquery.validate.min.js:16 Uncaught ReferenceError: jQuery is not defined at jquery.validate.min.js:16 jquery.validate.unobtrusive.min.js:19 Uncaught ReferenceError: jQuery is not defined at jquery.validate.unobtrusive.min.js:19 Index:1436 Uncaught TypeError: $(...).datepicker is not a function at HTMLDocument. (http://localhost:60585/(S(yjivkav5ujyyjrcrznjabbqp))/Home/Index:1436:26) at i (http://localhost:60585/template/web/js/jquery-2.2.3.min.js:2:27151) at Object.fireWith [as resolveWith] (http://localhost:60585/template/web/js/jquery-2.2.3.min.js:2:27914) at Function.ready (http://localhost:60585/template/web/js/jquery-2.2.3.min.js:2:29707) at HTMLDocument.J (http://localhost:60585/template/web/js/jquery-2.2.3.min.js:2:29892)

但是当我尝试在页面底部找到所有这些脚本时,如下所示:

<script src="/template/web/js/jquery-ui.js"></script>
<script src="~/Scripts/jquery.validate.min.js"></script>
<script src="~/Scripts/jquery.validate.unobtrusive.min.js"></script>
<script src="~/Scripts/jquery-1.10.2.min.js"></script>

将会出现这些错误:

Uncaught TypeError: $(...).ziehharmonika is not a function at HTMLDocument. (http://localhost:60585/(S(ls4ko4ghxnphalf2azyphinz))/Home/Index:1462:23) at i (http://localhost:60585/template/web/js/jquery-2.2.3.min.js:2:27151) at Object.fireWith [as resolveWith] (http://localhost:60585/template/web/js/jquery-2.2.3.min.js:2:27914) at Function.ready (http://localhost:60585/template/web/js/jquery-2.2.3.min.js:2:29707) at HTMLDocument.J (http://localhost:60585/template/web/js/jquery-2.2.3.min.js:2:29892) Index:1441 Uncaught TypeError: $(...).JiSlider is not a function at http://localhost:60585/(S(ls4ko4ghxnphalf2azyphinz))/Home/Index:1441:20 at dispatch (http://localhost:60585/template/web/js/jquery-2.2.3.min.js:3:7537) at r.handle (http://localhost:60585/template/web/js/jquery-2.2.3.min.js:3:5620)

最佳答案

您需要将这个(加载 jQuery)放在脚本列表的第一位:

<script src="~/Scripts/jquery-1.10.2.min.js"></script>

关于javascript - 我应该如何在网页中找到我的脚本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47773140/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com