日期插件datepicker的使用

一、下載日期插件datepicker的moment.js、jquery-datePicker.min.js、index.csscss

 

 

 

 

二、編寫日期插件樣式vue

 

<div class="date_select_box_resouce" style="line-height: 80px;">
       <div class="date_select_title_resouce">日期:</div>
        <div class="date_select_value_resouce" >
            <input class="datePicker_box"  name="todayDate" type="text" placeholder="請選擇日期..." v-model='todayDate' readonly />
        </div>
</div> 

  日期插件樣式:java

 

/* 日期空間框的樣式 */
	.date_select_box_resouce {
	    font-size: 24px;
	    display: flex;
	    line-height: 52px;
	    margin-top: 20px;
	}
	
	.date_select_title_resouce {
	    width: 100px;
	}
	
	.date_select_value_resouce {
	    flex: 1;
	}
	
	.date_select_box_resouce .date_select_value_resouce select, .date_select_box_resouce .date_select_value_resouce input {
	    width: 252px;
	    height: 50px;
	    line-height: 50px;
	    padding: 8px;
	    box-sizing: border-box;
	    background-color: rgba(7, 27, 34, 85%);
	    color: #FFFFFF;
	    font-size: 24px;
	    border: none;
	}

  效果以下:jquery

 

 

 

 

三、代碼實現面試

 

$('.datePicker_box').on('click', function () {
	var _this = this;
	if(!$(this).next('[name="datePicker"]').length) {
		$(this).after("<div class='datePicker-x' name='datePicker'></div>");
			datePicker = $('.datePicker-x').datePicker({
				reportTimeType: 5, // 4表明小時、5表明天、6表明周、7表明月、8表明季、9表明年
				startDom: $(_this),  // 開始時間要賦值的DOM元素
				format: 'YYYY-MM-DD HH:mm:ss',
				isFast: false,   // 是否顯示快速選擇的選項
				isDouble: false,   // 是否雙選擇的日曆
				disabledDate: false,    // 是否禁用之後的時間
				yes: function (startTime, endTime) {    // 成功賦值前的回調可改變賦值的時間格式
					catchzbList(startTime);
				},
			});
	}else {
		if($(this).next('[name="datePicker"]').hasClass('hide')) {
			$(this).next('[name="datePicker"]').removeClass('hide');
			datePicker.render();
		}else {
			$(this).next('[name="datePicker"]').addClass('hide');

		}
	}
});

  效果以下:數組

 

 

 

 

時間處理(vue寫法):ide

 

mounted: function() {
        let that = this
        //時間處理
		let year = new Date().getFullYear()
        let month = new Date().getMonth() + 1
        let day = new Date().getDate()
        month = month > 9 ? month.toString() : '0' + month
        day = day > 9 ? day.toString() : '0' + day
        this.year = year
        this.month = month
        this.day = day
        //執行的
        window.catchReList = this.getResourceList2;
        //設置彈窗頁面的顯示位置
        that.markObj.forEach(i=>{
        	if(i.name=='resources'){
        		that.mark={top:i.top,right:i.right,left:i.left};
        	}
        })
 }

  接口調用(vue寫法):學習

 

getResourceList2: function(selDate, pageNum = 1) { //查詢保電資源投入列表
    	let that = this
    	var currDate= "";
        if(selDate != '' && selDate != undefined){
        	currDate = selDate.substring(0,10);
        }else{
        	currDate=that.year+'-'+that.month+"-"+that.day;
        }
        //每次調用前對數組進行置空
        this.todayDate = currDate
    	Post(API.queryReourceList, { pageNum: pageNum, pageSize: 9 , pageEvent: Vm.pageEvent, selDate: currDate}, function(res) {
    		let resArr = JSON.parse(res.resultValue)
    		console.log(resArr);
    		that.resourceList = resArr.items
    		that.pageInfo.pageNum = resArr.pageNum
    		that.pageInfo.maxNum = resArr.maxPage
    		that.pageInfo.toalNum = resArr.toalNum
    		
    		that.numberArrFun(resArr.pageNum, resArr.maxPage)
    		
    	})
   }

更多java、大數據學習面試資料,請掃碼關注個人公衆號:大數據

 

相關文章
相關標籤/搜索