麻豆小视频在线观看_中文黄色一级片_久久久成人精品_成片免费观看视频大全_午夜精品久久久久久久99热浪潮_成人一区二区三区四区

首頁 > 課堂 > 小程序 > 正文

微信小程序日歷/日期選擇插件使用方法詳解

2020-03-21 16:03:50
字體:
來源:轉載
供稿:網友

微信小程序日歷選擇器插件點擊日歷日期可以獲取到年月日,具體內容如下

微信小程序,日歷,日期選擇

wxml

<view class="canlendarBgView"> <view class="canlendarView">  <view class="canlendarTopView">   <view class="leftBgView" bindtap="handleCalendar" data-handle="prev">    <view class="leftView">《</view>   </view>   <view class="centerView">{{cur_year || "--"}} 年 {{cur_month || "--"}} 月</view>   <view class="rightBgView" bindtap="handleCalendar" data-handle="next">    <view class="rightView">》</view>   </view>  </view>  <view class="weekBgView">   <view class="weekView" wx:for="{{weeks_ch}}" wx:key="{{index}}" data-idx="{{index}}">{{item}}</view>  </view>  <view class="dateBgView">   <view wx:if="{{hasEmptyGrid}}" class="dateEmptyView" wx:for="{{empytGrids}}" wx:key="{{index}}" data-idx="{{index}}">   </view>   <view class="dateView" wx:for="{{days}}" wx:key="{{index}}" data-idx="{{index}}" bindtap="dateSelectAction">    <view class="datesView {{index == todayIndex ? 'dateSelectView' : ''}}">{{item}}</view>   </view>  </view> </view> <view>點擊日期選擇</view></view>

js

//index.js//獲取應用實例Page({ data: {  hasEmptyGrid: false,  cur_year: '',  cur_month: '', }, onLoad(options) {  this.setNowDate(); },  dateSelectAction: function (e) {  var cur_day = e.currentTarget.dataset.idx;  this.setData({   todayIndex: cur_day  })  console.log(`點擊的日期:${this.data.cur_year}年${this.data.cur_month}月${cur_day + 1}日`); },  setNowDate: function () {  const date = new Date();  const cur_year = date.getFullYear();  const cur_month = date.getMonth() + 1;  const todayIndex = date.getDate() - 1;  console.log(`日期:${todayIndex}`)  const weeks_ch = ['日', '一', '二', '三', '四', '五', '六'];  this.calculateEmptyGrids(cur_year, cur_month);  this.calculateDays(cur_year, cur_month);  this.setData({   cur_year: cur_year,   cur_month: cur_month,   weeks_ch,   todayIndex,  }) },  getThisMonthDays(year, month) {  return new Date(year, month, 0).getDate(); }, getFirstDayOfWeek(year, month) {  return new Date(Date.UTC(year, month - 1, 1)).getDay(); }, calculateEmptyGrids(year, month) {  const firstDayOfWeek = this.getFirstDayOfWeek(year, month);  let empytGrids = [];  if (firstDayOfWeek > 0) {   for (let i = 0; i < firstDayOfWeek; i++) {    empytGrids.push(i);   }   this.setData({    hasEmptyGrid: true,    empytGrids   });  } else {   this.setData({    hasEmptyGrid: false,    empytGrids: []   });  } }, calculateDays(year, month) {  let days = [];   const thisMonthDays = this.getThisMonthDays(year, month);   for (let i = 1; i <= thisMonthDays; i++) {   days.push(i);  }   this.setData({   days  }); }, handleCalendar(e) {  const handle = e.currentTarget.dataset.handle;  const cur_year = this.data.cur_year;  const cur_month = this.data.cur_month;  if (handle === 'prev') {   let newMonth = cur_month - 1;   let newYear = cur_year;   if (newMonth < 1) {    newYear = cur_year - 1;    newMonth = 12;   }    this.calculateDays(newYear, newMonth);   this.calculateEmptyGrids(newYear, newMonth);    this.setData({    cur_year: newYear,    cur_month: newMonth   })   } else {   let newMonth = cur_month + 1;   let newYear = cur_year;   if (newMonth > 12) {    newYear = cur_year + 1;    newMonth = 1;   }    this.calculateDays(newYear, newMonth);   this.calculateEmptyGrids(newYear, newMonth);    this.setData({    cur_year: newYear,    cur_month: newMonth   })  } }})

以上就是本文的全部內容,希望對大家的學習有所幫助,也希望大家多多支持VEVB武林網。


發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 色诱亚洲精品久久久久久 | 久久久久99999| 日韩黄色成人 | 久久亚洲春色中文字幕久久 | 91美女视频在线观看 | 日本教室三级在线看 | 午夜精品成人 | 久久艹精品 | 日本在线不卡一区二区三区 | 免费国产人成网站 | 韩国精品视频在线观看 | 国产精品av久久久久久网址 | 亚洲乱码精品久久久久 | 精品一区二区三区免费看 | 国产精品视频不卡 | 男女一边摸一边做羞羞视频免费 | 精品国产亚洲人成在线 | 黑色丝袜美美女被躁视频 | 黄色一级片免费在线观看 | 高清做爰免费无遮网站挡 | 成人勉费视频 | 斗罗破苍穹在线观看免费完整观看 | www.54271.com| 欧美成人一区二区三区电影 | 看91| 国产一区精品在线观看 | 色戒在线版| 国产精品久久久久久久久久久久久久久久 | 久久999精品久久久 国产噜噜噜噜久久久久久久久 | 一级免费黄视频 | 免费一级欧美在线观看视频 | 狠狠干夜夜草 | 斗罗破苍穹在线观看免费完整观看 | 色网站综合 | 亚洲va久久久噜噜噜久久男同 | 午夜视频在线观看免费视频 | 性欧美日本 | 中国洗澡偷拍在线播放 | 国产99视频在线观看 | 亚洲第一成人在线视频 | 久久毛片免费观看 |