vant 에서 시간 선택 기와 팝 업 팝 업 팝 업 팝 업 을 사용 합 니 다.

긴 말 안 할 게 요.그냥 코드 보 세 요~

<template> 
 <div class="page">
  <van-cell-group>
      <van-cell
       title="    "
       :value="datetime"
       arrow
       @click="showDatePicker = !showDatePicker"
      ></van-cell>
 </van-cell-group>
 <van-popup v-model="showDatePicker" position="bottom" :style="{ height: '40%' }">
   <van-datetime-picker
    v-model="currentDate"
    @confirm="
     showDatePicker = false;
     onchangDate1();
    "
    @cancel="showDatePicker = false"
    title="    "
    type="date"
   />
  </van-popup>
 </div>
<template>
<script>
  import { Cell, CellGroup, DatetimePicker, Popup } from "vant";
  import Vue from "vue";
  export default {
   //   Q2        ,       
   components: {
     [Cell.name]: Cell,
     [CellGroup.name]: CellGroup,
     [DatetimePicker.name]: DatetimePicker,
     [Popup.name]: Popup
   },
 //   
 data() {
  return {
   datetime: "",
   currentDate: "",  //       
   showDatePicker: false, //  popup       ,false   
  };
 },
 created() {
  this.currentDate = new Date();  //       
  this.datetime = this.common.dateToString(this.currentDate);  //               
 },
 mounted() {},
 methods: {
  onchangDate1() {
   //currentDate        ,                
   this.datetime = this.common.dateToString(this.currentDate);  
  }
 }
};
</script>
추가 지식:vant 의 popup,Datetimepicker 컨트롤 스크롤 관통
오늘 버그 를 고치 면서 테스트 를 해 보 니 vant 의 popup 과 DatetimePicker 에 스크롤 관통 이 나타 날 것 입 니 다.
해결 방법:preventDefault 를 사용 하여 body 의 touch move 사건 을 막 습 니 다.
방법


방법
전역 에 v-roll 명령 을 등록 하고 timeDatePicker 와 결합 하여 사용 합 니 다(예 를 들 어 두 번 째 그림).body Visible 의 초기 상 태 는 false 입 니 다.탄 층 이 열 릴 때 바 뀌 고 탄 층 이 확인 을 클릭 하고 취소 할 때 도 바 뀌 어야 합 니 다!


해결 방법 은 다른 작가 의 글 링크 에서 비롯 되 었 다.
이 편 은 vant 에서 시간 선택 기와 팝 업 팝 업 팝 업 팝 업 팝 업 층 을 사용 하 는 작업 이 바로 작은 편집 이 여러분 에 게 공유 하 는 모든 내용 입 니 다.참고 하 시기 바 랍 니 다.여러분 들 도 많이 응원 해 주 셨 으 면 좋 겠 습 니 다.

좋은 웹페이지 즐겨찾기