pages/日历.vue
<template>
<view>
<view class="date-choose shrink">
<view class="data-month">{
{
dateMonth }}</view>
<swiper class="date-choose-swiper" :indicator-dots="false" :current="swiperCurrent" @change="dateSwiperChange($event)">
<block v-for="(date,index) in dateList">
<swiper-item class="swiper-item">
<view class="weekday">
<block v-for="(weekday,ind) in dateListArray">
<text class="week">{
{
weekday }}</text>
</block>
</view>
<view class="dateday">
<block v-for="day in date.days" :key="day.id">
<text class="day" :id="day.id" @tap="chooseDate($event)">
<text :class="dateCurrentStr==day.id?'active':''">{
{
day.day }}</text>
</text>
</block>
</view>
</swiper-item>
</block>
</swiper>
</view>
</view>
</template>
<script>
export default {
data() {
return {
dateList: [],
swiperCurrent: 0,
dateCurrent: new Date(),
dateCurrentStr: '',
dateMonth: '1月',
dateListArray: ['日', '一', '二', '三', '四', '五', '六']
};
},
onLoad() {
var that = this;
this.initDate();
},
methods: {
initDate