1. 程式人生 > 實用技巧 >用日期獲取周幾

用日期獲取周幾

<view class="weeks">
	<text @click="switchWeek(index)" v-for="(item,index) in ['周天',' 週一','週二','週三','週四','週五','週六']" class="item zk_pressed1"
	:class="{active:curWeekIndex==index}">{{item}}</text>
</view>

  

data() {
            return {
              
                curWeekIndex: 
0, } },
methods:

            switchWeek(index: any) {
                
                this.curWeekIndex = index;
                
            },
                    
//在獲取打卡列表的裡寫

  getRecord(date:any){
var that:any = this var
weekDay = ["星期天", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六"]; var b = new Date(Date.parse(date.replace(/\-/g,"/"))); // console.log(b.getDay()); console看一下 this.curWeekIndex = b.getDay(); },