切换日期选择,可按月/按日,根据自身修改
如下图所示
代码如下:
父页面
//html
<view class="content_row_next">
<text @click="getTime(1)">{{StatisticsCurrent==0?SStartSearchDate.substr(0,7):SStartSearchDate}}</text>
<image src="/static/ic_showOther_contat.png" v-if="StatisticsCurrent==1"></image>
<text @click="getTime(2)" v-if="StatisticsCurrent==1">{{SEndSearchDate}}</text>
</view>
//使用一个子组件的话,防止日期串,可设置不同的ref,进行区别
<cwDatePicker :current="current" @sonFlagMsg="sonPipkerFlag" @onCancel="onCancel" @onConfirm="onStartConfirm"
:startDate="from_startDefaultDate" :endDate="from_endDefaultDate" :defaultValue="startSearchDate"
ref="cwDatePicker">
</cwDatePicker>
<cwDatePicker :current="current" @sonTFlagMsg="sonTPipkerFlag" @onCancel="onCancel" @onConfirm="onEndConfirm"
:startDate="to_startDefaultDate" :endDate="to_endDefaultDate" :defaultValue="endSearchDate"
v-if="current==1" ref="dyptDatePicker">
</cwDatePicker>
//js
getTime: function(e) {
if (e == 1) {
this.$refs.cwDatePicker.show();
} else if (e == 2) {
this.$refs.dyptDatePicker.show();
}
},
日期子组件,参考另一篇
https://blog.csdn.net/jinjina_/article/details/120045499