gpt4 book ai didi

jquery - Uncaught ReferenceError : $ is not defined after applying Bootstrap Template

转载 作者:行者123 更新时间:2023-12-01 21:55:23 24 4
gpt4 key购买 nike

我正在做一个 MVC 项目。我下载了一个名为 argon 的 Bootstrap 主题并尝试与 MVC 集成。我在 Bundle.Config 中引用了所有与 Argon 相关的 css 和 javascript 文件。 我认为它已成功集成,并且我现在可以使用所有 argon html 元素。 问题是我无法正确使用 jquery 函数。我在所有其他插件的顶部添加了 jquery 引用。但总是得到这个错误 - “ Uncaught ReferenceError :$ 未定义”。 我搜索了一下,我知道这是一个很常见的问题,但没有找到合适的解决方案。 不确定我在哪里犯了错误。

Any suggestion would be helpful. TIA.


This is what I have tried -

Bundle Config File :

bundles.Add(new ScriptBundle("~/bundles/jquery").Include(
"~/Scripts/jquery-{version}.js",
"~/Argon/assets/vendor/jquery/jquery.min.js",
"~/Argon/assets/js/argon.min.js",
"~/Argon/assets/vendor/popper/popper.min.js",
"~/Argon/assets/vendor/bootstrap/bootstrap.min.js",
"~/Argon/assets/vendor/headroom/headroom.min.js",
"~/Argon/assets/vendor/onscreen/onscreen.min.js",
"~/Argon/assets/vendor/nouislider/js/nouislider.min.js",
"~/Argon/assets/vendor/bootstrap-datepicker/js/bootstrap-datepicker.min.js"
));

bundles.Add(new ScriptBundle("~/bundles/jqueryval").Include(
"~/Scripts/jquery.validate*"));

// Use the development version of Modernizr to develop with and learn from. Then, when you're
// ready for production, use the build tool at https://modernizr.com to pick only the tests you need.
bundles.Add(new ScriptBundle("~/bundles/modernizr").Include(
"~/Scripts/modernizr-*"));

bundles.Add(new ScriptBundle("~/bundles/bootstrap").Include(
"~/argon/assets/vendor/bootstrap/bootstrap.js",
"~/argon/assets/vendor/bootstrap/bootstrap.min.js"));

bundles.Add(new StyleBundle("~/Content/css").Include(
"~/Content/bootstrap.css",
"~/Content/site.css"));

bundles.Add(new StyleBundle("~/Content/argon").Include(
"~/Argon/assets/css/argon.min.css",
"~/Argon/assets/css/bootstrap/bootstrap-grid.min.css",
"~/Argon/assets/css/bootstrap/bootstrap-reboot.min.css",
"~/Argon/assets/vendor/bootstrap-datepicker/css/bootstrap-datepicker.min.css",
"~/Argon/assets/vendor/font-awesome/css/font-awesome.min.css",
"~/Argon/assets/vendor/nouislider/css/nouislider.min.css",
"~/Argon/assets/vendor/nucleo/css/nucleo-svg.css",
"~/Argon/assets/vendor/nucleo/css/nucleo.css"
));



THE LAYOUT PAGE:


@Styles.Render("~/Content/css")
@Styles.Render("~/Content/argon")
@Scripts.Render("~/bundles/modernizr")

<div class="container body-content">
@RenderBody()
<hr />
<footer>
<p>&copy; @DateTime.Now.Year - My ASP.NET Application</p>
</footer>
</div>

@Scripts.Render("~/bundles/jquery")
@*@Scripts.Render("~/bundles/bootstrap")*@
@RenderSection("scripts", required: false)
</body>
</html>



THE INDEX PAGE:

@{
ViewBag.Title = "Home Page";
}


<div>
<div class="form-group">
<div class="input-group input-group-alternative">
<div class="input-group-prepend">
<span class="input-group-text"><i class="ni ni-calendar-grid-58"></i></span>
</div>
<input class="form-control datepicker" id="dtTime" placeholder="Select date" type="text"/>
<button type="button" id="btnDate" class="btn btn-outline-default">Default</button>
</div>
</div>


</div>


<script type="text/javascript">
$(document).ready(function () {
$("#btnDate").on('click', function (e) {
var dtval = $('.datepicker').val();
console.log(dtval);
});

});

</script>

最佳答案

我不需要掌声,但要补充:

<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>

在你的 <script> 之前标签或 <head></head>

关于jquery - Uncaught ReferenceError : $ is not defined after applying Bootstrap Template,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57930532/

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