效果图
<template>
<view class="content">
<picker
mode="date"
:value="date"
fields="month"
@change="bindDateChange"
>
<view style="display: flex;width: 120%;align-items: center;">
<view style="margin-left:15rpx;margin-right:15rpx;font-size:35rpx;color:#000000">
本月</view>
{{date}}
</view>
</picker>
</view>
</template>
<script>
export default {
data() {
return {
date:''
}
},
onLoad() {
this.getInitDate()
},
methods: {
getInitDate(){
var date = new Date()
var year = date.getFullYear()
var month = date.getMonth()+1
if(month/10<1) month='0'+month
this.date = year+'-'+month
},
bindDateChange(e){
this.date = e.target.value;
}
}
}
</script>
<style>
</style>