对象不支持属性或方法日期选择器

2024-04-25

我试图在我的页面中放置一个日期选择器并收到此错误。我已经搜索并寻找此错误的其他答案,但找不到任何答案。

如果没有对于引导程序部分,它有效;但有了它,我收到了这个错误。这背后的原因是什么?我该如何解决这个问题?

这是我的index.cshtml:

@{
    Layout = null;
}

<!DOCTYPE html>

<html lang="en">
<head>

    @Scripts.Render("~/bundles/jquery")
    @Scripts.Render("~/bundles/jqueryui")
    @Styles.Render("~/Content/css")
    @Scripts.Render("~/bundles/modernizr")
    @Scripts.Render("~/bundles/Chart")
    @Scripts.Render("~/bundles/moment")
    <meta charset="utf-8" />
    <title>ENOCTA DASHBOARD</title>

    <!-- FOR DATEPICKER -->
    <link rel="stylesheet" href="//code.jquery.com/ui/1.11.4/themes/smoothness/jquery-ui.css">
    <script src="//code.jquery.com/jquery-1.10.2.js"></script>
    <script src="//code.jquery.com/ui/1.11.4/jquery-ui.js"></script>
    <link rel="stylesheet" href="/resources/demos/style.css">
    <script>
        $(function () {
            $("#datepicker").datepicker();
        });
    </script>

    <!-- FOR BOOTSTRAP -->
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css">
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
    <script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>

</head>

<body>
    <p>Date: <input type="text" id="datepicker"></p>
</body>

</html>

页面上有 2 个版本的 jQuery,jQuery UI 日期选择器将自身挂入第一个版本,然后第二个版本覆盖第一个版本,因此当DOMContentReady事件被触发。解决方案是将第二个 jquery include 向上移动并删除第一个:

<!-- FOR DATEPICKER -->
<link rel="stylesheet" href="//code.jquery.com/ui/1.11.4/themes/smoothness/jquery-ui.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<script src="//code.jquery.com/ui/1.11.4/jquery-ui.js"></script>
<link rel="stylesheet" href="/resources/demos/style.css">
<script>
    $(function () {
        $("#datepicker").datepicker();
    });
</script>

<!-- FOR BOOTSTRAP -->
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css">
<script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

对象不支持属性或方法日期选择器 的相关文章

随机推荐