iview日期控件 双向绑定日期
生活随笔
收集整理的這篇文章主要介紹了
iview日期控件 双向绑定日期
小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
官網(wǎng)查看iview
準(zhǔn)備工作
import { getDate, getTime } from '@/libs/util'@/libs/util
/*** @description 日期時(shí)間轉(zhuǎn)換時(shí)間戳*/ export const getTime = dt => {return dt ? new Date(dt).getTime() : new Date().getTime() }/*** @description 時(shí)間戳轉(zhuǎn)換日期時(shí)間*/ export const getDate = (format, dt) => {dt = dt ? new Date(dt) : new Date()const t = {'M+': dt.getMonth() + 1, // 月份'd+': dt.getDate(), // 日'H+': dt.getHours(), // 小時(shí)'m+': dt.getMinutes(), // 分's+': dt.getSeconds(), // 秒'S': dt.getMilliseconds() // 毫秒}if (/(y+)/.test(format)) {format = format.replace(RegExp.$1, (dt.getFullYear() + '').substr(4 - RegExp.$1.length))}for (let k in t) {if (new RegExp('(' + k + ')').test(format)) { format = format.replace(RegExp.$1, (RegExp.$1.length === 1) ? (t[k]) : (('00' + t[k]).substr(('' + t[k]).length))) }}return format }data里數(shù)據(jù)
data () {return {pubTime: getDate('yyyy-MM-dd'),options: {disabledDate (date) {return date && date.valueOf() < Date.now() - 86400000}},}}頁(yè)面
<DatePickertransfer:options="options":value="pubTime"style="width: 200px"type="date"placeholder="點(diǎn)擊選擇時(shí)間"format="yyyy-MM-dd"@on-change="pubTime = $event"/>重點(diǎn)代碼
@on-change="pubTime = $event"
總結(jié)
以上是生活随笔為你收集整理的iview日期控件 双向绑定日期的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: 2022年五年期国债利率,利率为3.52
- 下一篇: 什么是限制性股票