返回

javascript-Jquery不再在ASP中工作。NET Core 6,Jquery 3.6.0版

发布时间:2022-03-28 18:49:47 309
# 前端

我在这里完全不知所措。我的项目中有一个本地版本(3.6.0)的Jquery,它突然停止注册$()或Jquery()命令。如果断点命中,它会无休止地循环,这是一个很大的if。我确实使用F5和F11更快地穿过无休止的断点。

$(document).ready(function () {
    alert("works");
});

通过上面的测试,我一直在使用它来测试Jquery是否能够正常工作。我有两个断点,一个在1号线,一个在2号线;1次命中,2次从未执行。所以我认为问题在两者之间。但我不确定是怎么回事。

我已经剥离了我的应用程序中的任何其他库,并多次重新安装了Jquery。下面是我的利伯曼。json和我的wwwroot的屏幕截图

{
  "version": "1.0",
  "defaultProvider": "cdnjs",
  "libraries": [
    {
      "library": "jquery@3.6.0",
      "destination": "wwwroot/lib/jquery/"
    }
  ]
}

wwwroot-expanded

还有我正在使用的layout razor文件,它位于views/shared/_layout中。cshtml

@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers

<!DOCTYPE html>
<html class="siteBackground" lang="en-us">

<head>

    <meta name="viewport" content="width=device-width, initial-scale=1.0, shrink-to-fit=no" />
    <meta charset="utf-8" />

    <title>Lotus Transformation</title>

    
    <script type="text/javascript" src="~/lib/jquery/jquery.min.js"></script>
    <script type="text/javascript" src="~/CustomJavascript/LayoutResponsiveness.js"></script>
    <link rel="stylesheet" type="text/css" href="~/CustomCss/LayoutCustom.min.css"/>
    <link rel="stylesheet" type="text/css" href="~/CSS/CSSReset.css" />

</head>
<body class="LayoutBody">
    <header class="header">

        <a asp-controller="LotusGeneral" asp-action="Home"><img class="logo" src="~/Images/Logo/R.png" /></a>
        
        <a asp-controller="LotusGeneral" asp-action="Home"><h1 class="title">LotusTransformation</h1></a>
        <a asp-controller="LotusGeneral" asp-action="Home"><h2 class="subtitle">Holistic Health and Wellness Coaching</h2></a>

        <nav class="navbar">
            <ul class="navUl">
                <a asp-controller="LotusGeneral" asp-action="Home"><li class="navLi">Home</li></a>
                <a asp-controller="LotusGeneral" asp-action="About"><li class="navLi">About</li></a>
                <a asp-controller="LotusGeneral" asp-action="Services"><li class="navLi">Appointments</li></a>
                <a asp-controller="LotusGeneral" asp-action="Meditations"><li class="navLi">Meditations</li></a>
                <a asp-controller="LotusGeneral" asp-action="Inspiration"><li class="navLi">Inspirations</li></a>
                <li></li>
            </ul>
        </nav>

        <a asp-controller="SignIn" asp-action="SignIn"><button class="LogInButton"> Log In/Sign Up</button></a>
    </header>
    <div class="SpecificPageContent">
        @RenderBody();
    </div>
    <footer class="footer">
        <p>&copy;LotusTransformation LLC</p>
        <p>filler</p>
        <p>filler</p>
        <p>filler</p>
    </footer>
</body>
</html>


我不知道为什么jquery不工作,它以前从来没有给我带来这么多麻烦。我觉得我错过了一些显而易见的东西,但我却不知道那是什么。

这14个警告与我的一些正常化有关。scss文件,我没有看到任何影响,此外,jquery昨天晚上工作正常,没有对。从昨天下午开始。

我有:

  1. 移除了所有其他对JQuery库的引用(没有jquery-ui、validation.js等。)
  2. 通过NPM和添加客户端库卸载/重新安装jquery
  3. 除了下面的屏幕截图之外,没有安装其他库或包。
  4. 确保jquery是加载的第一个脚本。
  5. 我在网上和教科书中搜索了多种资源。

我想我已经在另一个用户的帮助下修复了它,然而,JQuery又一次停止了工作。我得到的错误是,它甚至不会命中断点。连$(文档)都没有。ready(函数(){ });被击中了。下面是我尝试使用的Jquery:

$(document).ready(function () {

    var initial;

        initial = $(window).width() * .75;
        $('.navbar').css('right', initial);
    
    var previous = 0;

    $(window).on('resize', function () {

        var navmoves = ((($(window).width() * .75) / 100));

        if (previous == 0) {
            if ((initial - navmoves) < 0) {
                navmoves = -navmoves;
                $('.navbar').css("right", navmoves);
            } else {
                $('.navbar').css("right", navmoves);
            }
        } else {
            if (previous != 0) {
                 navmoves = previous - navmoves;
                 $('.navbar').css("right", navmoves);
        }
    }
    previous = abs(navmoves);

    });
 });


如果一部分代码不工作,或者有逻辑错误,我会理解,但是Jquery会完全停止工作...我不明白。

我修正了之前指出的引用错误,但是它似乎在工作;似乎一旦我编写了更复杂的代码,它就会崩溃。简单的报警电话不起作用。自从它恢复运行以来,我唯一更新的是jQuery文件,没有更新任何包、库、链接等

特别声明:以上内容(图片及文字)均为互联网收集或者用户上传发布,本站仅提供信息存储服务!如有侵权或有涉及法律问题请联系我们。
举报
评论区(0)
按点赞数排序
用户头像