時間選擇器默認當前時間


默認在時間選擇器里面

 js文件

// 時間格式化
// Format 在組件created里引用
Date.prototype.Format = function (fmt) { // author: meizz var o = { "M+": this.getMonth() + 1, // 月份 "d+": this.getDate(), // "h+": this.getHours(), // 小時 "m+": this.getMinutes(), // "s+": this.getSeconds(), // "q+": Math.floor((this.getMonth() + 3) / 3), // 季度 "S": this.getMilliseconds() // 毫秒 }; if (/(y+)/.test(fmt)) fmt = fmt.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length)); for (var k in o) if (new RegExp("(" + k + ")").test(fmt)) fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length))); return fmt; }

組件

<el-form :inline="true" :model="filters">
      <el-form-item label="發起時間:" prop="dateranTime">
            <el-date-picker
              v-model="filters.effectiveTime"
              type="daterange"
              range-separator=""
              start-placeholder="開始日期"
              end-placeholder="結束日期"
              :default-time="['00:00:00', '23:59:59']"
              value-format="yyyy-MM-dd HH:mm:ss"
            ></el-date-picker>
          </el-form-item>
</el-form>

// 別忘了引入js文件哦~
created(){
// this.filters.effectiveTime 是上面 v-model綁定的 this.filters.effectiveTime = [ new Date().Format("yyyy-MM-dd") + " 00:00:00", new Date().Format("yyyy-MM-dd") + " 23:59:59", ]; // Format是js文件里的 }

 


免責聲明!

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



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