时间:2021-05-28
datepicker插件默认为英文,而且格式为:mm/dd/yyyy这种情况,看起来不怎么直观。
修改目标:
1、默认显示为中文
2、格式为:yyyy年mm月dd日
需要修改两个地方:
1、更改datas对象, 增加zh-cn语言选项;参见源代码的1419行
var dates = $.fn.datepicker.dates = { en: { days: ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"], daysShort: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"], daysMin: ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa", "Su"], months: ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"], monthsShort: ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"], today: "Today", clear: "Clear" }, "zh-cn":{ days: ["星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六", "星期日"], daysShort: ["周日", "周一", "周二", "周三", "周四", "周五", "周六", "周日"], daysMin: ["日", "一", "二", "三", "四", "五", "六", "日"], months: ["一月份", "二月份", "三月份", "四月份", "五月份", "六月份", "七月份", "八月份", "九月份", "十月份", "十一月份", "十二月份"], monthsShort: ["一月", "二月", "三月", "四月", "五月", "六月", "七月", "八月", "九月", "十月", "十一月", "十二月"], today: "今天", clear: "清空" } };红色部分为新增部分。
2、修改默认参数,即defaults对象。
var defaults = $.fn.datepicker.defaults = { autoclose: false, beforeShowDay: $.noop, calendarWeeks: false, clearBtn: false, daysOfWeekDisabled: [], endDate: Infinity, forceParse: true, format: 'yyyy年mm月dd日', keyboardNavigation: true, language: 'zh-cn', minViewMode: 0, multidate: false, multidateSeparator: ',', orientation: "auto", rtl: false, startDate: -Infinity, startView: 0, todayBtn: false, todayHighlight: false, weekStart: 0 };3、效果如下
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持。
声明:本页内容来源网络,仅供用户参考;我单位不保证亦不表示资料全面及准确无误,也不保证亦不表示这些资料为最新信息,如因任何原因,本网内容或者用户因倚赖本网内容造成任何损失或损害,我单位将不会负任何法律责任。如涉及版权问题,请提交至online#300.cn邮箱联系删除。
bootstrap-datepicker是一个非常优秀的时间选择插件,默认是英文显示日期的,通过下面几个小修改让其支持默认中文1、首先将bootstrap-da
bootstrap-datepicker是一个非常优秀的时间选择插件,默认是英文显示日期的。本文给大家介绍bootstrapdatepicker带中文的js文件
datepicker控件默认是英文的,可以在构造datepicker时通过monthNames、dayNames属性来指定月、日的中文显示值,但是每次使用是都配
在CentOS7系统上安装KDE后,默认显示的是英文。修改为中文的步骤如下:1、查看可用的中文安装包#yumlistkde*chinese2、安装中文包#yum
bootstrap-datepicker沙箱环境:bootstrap-datepicker沙箱环境:1、requirejs配置requirejs.config(