日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

使用Vant完成DatetimePicker 日期的选择器

發布時間:2024/9/27 编程问答 29 豆豆
生活随笔 收集整理的這篇文章主要介紹了 使用Vant完成DatetimePicker 日期的选择器 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

效果演示:

代碼

<template><div> <!-- 輸入框形式--><van-fieldreadonlyclickablename="calendar":value="timeValue"label="日期選擇:"placeholder="發生事故的時間點"@click="showPopFn()"/><br/><br/><!-- 按鈕框形式--><van-button plain type="primary" @click="showPopFn()">點擊選擇日期</van-button><van-field v-model="timeValue" placeholder="選擇的日期結果" readonly/><van-popup v-model="show" position="bottom" :style="{ height: '40%' }"><van-datetime-picker v-model="currentDate" type="date" @change="changeFn()" @confirm="confirmFn()"@cancel="cancelFn()"/></van-popup></div> </template><script>export default {data() {return {msg: '',currentDate: new Date(),changeDate: new Date(),show: false, // 用來顯示彈出層timeValue: ''}},methods: {showPopFn() {this.show = true;},showPopup() {this.show = true;},changeFn() { // 值變化是觸發this.changeDate = this.currentDate // Tue Sep 08 2020 00:00:00 GMT+0800 (中國標準時間)},confirmFn() { // 確定按鈕this.timeValue = this.timeFormat(this.currentDate);this.show = false;},cancelFn(){this.show = true;},timeFormat(time) { // 時間格式化 2019-09-08let year = time.getFullYear();let month = time.getMonth() + 1;let day = time.getDate();return year + '年' + month + '月' + day + '日'}},mounted() {this.timeFormat(new Date());}} </script><style> </style>

注意:如果是按需引入的話,記得在main.js里面引入相應的文件奧。

// main.js文件里面的部分代碼 import {Button} from 'vant' import { DatetimePicker } from 'vant'; import { Popup } from 'vant'; import { Field } from 'vant';Vue.use(Button) Vue.use(DatetimePicker) Vue.use(Popup) Vue.use(Field);

總結

以上是生活随笔為你收集整理的使用Vant完成DatetimePicker 日期的选择器的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。