uniapp 日期操作
<view class="promotionDetail-bot-title"> <view class="promotionDetail-bot-title-left">提成明细</view> <view class="promotionDetail-bot-title-right"> <view class="pDbtp-item">{{year||nowYear}}年</view> <image class="pDbtp-icon" mode="widthFix" src="/static/index_72.png"></image> <view class="pDbtp-item">{{month||nowMonth}}月</view> <image class="pDbtp-icon" mode="widthFix" src="/static/index_72.png"></image> <picker class="pDbtp-picker" :end='end' mode="date" fields="month" v-model="date" @change="dateChange"> <view class="pDbtp-picker-pad"></view> </picker> </view> </view> data() { return { year: '', month: '', nowYear: '', nowMonth: '', } }, onLoad(){ let now = new Date(); this.nowYear = now.getFullYear(); this.nowMonth = now.getMonth() + 1; this.end = `${this.nowYear}-${this.nowMonth}`; }, // 选择时间 dateChange(e) { console.log(e) let date = e.detail.value; this.year = date.match(/\d{4}/)[0]; this.month = Number.parseInt(date.match(/-(\d{2})/)[1]); },