Bootstrap 日期选择器显示不正确
Bootstrap Datepicker not displaying correctly
您好,我已经在我的 asp.net mvc 表单中添加了一个 bootstrap 日期选择器。
我将其设置为从十年开始显示年份。
但日期选择器仅将年份显示为一个较长的字符串,但它的功能
@section Scripts {
@Scripts.Render("~/bundles/jqueryval")
@Scripts.Render("~/bundles/bootstrap")
<script type="text/javascript">
$("#DateOfBirth").datepicker({
format: "dd/mm/yyyy",
startDate: "-120y",
endDate: "-10y",
startView: 2,
calendarWeeks: true,
defaultViewDate: { year: 1975, month: 01, day: 01 }
});
</script>
}
视图中的助手
<div class="row">
<div class="col-md-3 col-md-offset-1">
@Html.LabelFor(model => model.DateOfBirth, htmlAttributes: new { @class = "control-label" })
@Html.EditorFor(model => model.DateOfBirth, new { htmlAttributes = new { @class = "form-control", placeholder = "01/12/80" } })
@Html.ValidationMessageFor(model => model.DateOfBirth, "", new { @class = "text-danger" })
</div>
</div>
谢谢
它应该是什么样子:
实际情况:
正如 Jasen 所指出的,我错过了 css 资源,我是捆绑配置。谢谢
您好,我已经在我的 asp.net mvc 表单中添加了一个 bootstrap 日期选择器。 我将其设置为从十年开始显示年份。
但日期选择器仅将年份显示为一个较长的字符串,但它的功能
@section Scripts {
@Scripts.Render("~/bundles/jqueryval")
@Scripts.Render("~/bundles/bootstrap")
<script type="text/javascript">
$("#DateOfBirth").datepicker({
format: "dd/mm/yyyy",
startDate: "-120y",
endDate: "-10y",
startView: 2,
calendarWeeks: true,
defaultViewDate: { year: 1975, month: 01, day: 01 }
});
</script>
}
视图中的助手
<div class="row">
<div class="col-md-3 col-md-offset-1">
@Html.LabelFor(model => model.DateOfBirth, htmlAttributes: new { @class = "control-label" })
@Html.EditorFor(model => model.DateOfBirth, new { htmlAttributes = new { @class = "form-control", placeholder = "01/12/80" } })
@Html.ValidationMessageFor(model => model.DateOfBirth, "", new { @class = "text-danger" })
</div>
</div>
谢谢
它应该是什么样子:
实际情况:
正如 Jasen 所指出的,我错过了 css 资源,我是捆绑配置。谢谢