關於datepicker只顯示年、月、日的設置


關鍵時侯,還得看官方文檔。花了半個多小時,找了網上一大堆答復,然后一一驗證,90%沒有能解決問題。 
先給出官方文檔的URL: 
http://bootstrap-datepicker.readthedocs.io/en/latest/index.html

然后,直接上代碼。如下是只顯示月的sample code:

$("#datepicker").datepicker({
          language: "zh-CN",
          todayHighlight: true,
          format: 'yyyy-mm',
          autoclose: true,
          startView: 'months',
          maxViewMode:'years',
          minViewMode:'months'
});

 

問題的關鍵在三個參數的設置:startView, maxViewMode, minViewMode 
The view that the datepicker should show when it is opened. Accepts: 
0 or “days” or “month”, 
1 or “months” or “year”, 
2 or “years” or “decade”, 
3 or “decades” or “century”, 
4 or “centuries” or “millenium”.

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM