jquery-weui picker組件實現只選擇年月


 

    var date = new Date()
      var month = date.getMonth()+1  //獲取當前月份

      $('#selectTime').picker({
        toolbarTemplate:'<div class="toolbar"><div class="toolbar-inner"><a href="javascript:;" class="picker-button close-picker" style="color:#2F89FE;left: 0;right: auto;">取消</a><a href="javascript:;" class="picker-button close-picker" style="color:#2F89FE">完成</a></div></div>',
        cols:[
          {
            textAlign: 'left',
            values:(function () {//年份
        //從1970年開始到今年往后30年之間的范圍
              for(var years = [],k=1970;k<=date.getFullYear()+30;k++){
                years.push(k)
              }
              return years
            })()
          },
          {
            textAlign: 'right',
            values:(function () {//月份
              return "01 02 03 04 05 06 07 08 09 10 11 12".split(" ")
            })()
          }
        ],
        value:[date.getFullYear(),month<10?'0'+month:month],
        //改變時觸發
        onChange:function (re,val,displayValue) {
          // val當前選擇的值,displayValue當前顯示的值
        },
        //關閉時觸發
        onClose:function (e) {
          console.log(e)
        }
      });

 


免責聲明!

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



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