引用 bootsrtap-datatimepicker and bootstrap-datepicker 控件,發現官方控件不支持中文
1,bootstrap-datepicker - 》解決方法:
從GitHub上下載下面這個第三方的已經支持本地化的,https://github.com/eternicode/bootstrap-datepicker,
只需要下載2個文件
bootstrap-datepicker.js
bootstrap-datepicker.zh-CN.js即可。
調用:
<script src="/assets/js/date-time/bootstrap-datepicker.js"></script>
<script src="/assets/js/date-time/locales/bootstrap-datepicker.zh-CN.js"></script>
$('.date-picker').datepicker({
language: 'zh-CN',
autoclose: true,
todayHighlight: true
});
出處:http://blchen.com/make-bootstrap-datepicker-support-chinese/
2,bootstrap-datetimepicker - 》解決方法:
bootstrap-datetimepicker的本地化顯示依賴於moment插件。也就是說moment插件提供了多語言的內容支持,而bootstrap-datetimepicker沒有語言內容。
為此,如果需要支持簡體中文的顯示,就需要加載中文的資源文件。
在moment的官網,下載moment+locales.js,查找到’zh-CN’部分,另存為js文件,在moment.js和bootstrap-datetimepicker.js之間加載即可!
github:https://github.com/moment/moment
<script src=
"assets/thirdparty/bootstrap-datetimepicker/js/moment.js"
></script>
<script src=
"assets/thirdparty/bootstrap-datetimepicker/js/moment_zh-CN.js"
></script>
<script src=
"assets/thirdparty/bootstrap-datetimepicker/js/bootstrap-datetimepicker.js"
></script>
出處:http://www.myext.cn/c/a_6181.html
