我正在尝试解决区域问题(意大利),但没有成功,我视图中的脚本是:

    <script type="text/javascript"></script>
<script src="~/Scripts/jquery-ui-i18n.min.js"></script>
<script src="~/Scripts/jquery-ui-i18n.js"></script>
<script>
        $(function () {
            $('.datefield').datepicker({
                startDate: "-3d",
                maxViewMode: 3,
                todayBtn: "linked",
                multidate: false,
                autoclose: true,
                todayHighlight: true,
                toggleActive: true,
                FormData: "yyyy-MM-dd",
                regional:"it"
            });
            //$.datepicker.setDefaults($.datepicker.regional['it']);
            //$('.datefield').datepicker();
        });
</script>


但日期选择器是英文的。我不明白谢谢

最佳答案

您需要确保以正确的顺序包含jQuery,jQueryUI和jQueryUI的i18n库。尝试这个:



$(function() {
  $('.datefield').datepicker({
    startDate: "-3d",
    maxViewMode: 3,
    todayBtn: "linked",
    multidate: false,
    autoclose: true,
    todayHighlight: true,
    toggleActive: true,
    FormData: "yyyy-MM-dd"
  });
  $.datepicker.setDefaults($.datepicker.regional['it']);
});

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.0/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jqueryui/1.9.2/jquery-ui.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jqueryui/1.9.2/i18n/jquery-ui-i18n.js"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/jqueryui/1.9.2/themes/base/jquery-ui.min.css" />
<input type="text" class="datefield" />

10-08 18:23