第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問題,去搜搜看,總會(huì)有你想問的

VueJS Calendar 來回一個(gè)月

VueJS Calendar 來回一個(gè)月

波斯汪 2023-03-03 13:15:56
我已經(jīng)建立了一個(gè)顯示日期表和相應(yīng)日期的日歷,我想添加在月份之間更改的功能。我在這里制作的方法確實(shí)“有效”。當(dāng)我單擊具有此功能的按鈕時(shí),它可以追溯到一個(gè)月前。但只有一次,這是因?yàn)?selectedDate 沒有更新,所以當(dāng)我嘗試使用我注釋掉的 console.log(selectedDate) 進(jìn)行調(diào)試時(shí),它仍然打印今天的日期。希望有人能在這里幫助我methods: {  prevMonth() {    var selectedDate = moment(new Date());    let futureMonth = moment(selectedDate.subtract(1, 'month')).startOf('month')        selectedDate = futureMonth;    //return console.log(selectedDate)    this.days = [...Array(futureMonth.daysInMonth())].map((_, i) => {      return {        date: futureMonth.clone().add(i, "day"),        workhours: Math.floor(Math.random()*10),        overtime: Math.floor(Math.random()*10),        flextime: 0,        sickness: 0,        vacation: 0,      }    })  }}
查看完整描述

1 回答

?
手掌心

TA貢獻(xiàn)1942條經(jīng)驗(yàn) 獲得超3個(gè)贊

moment(new Date())每次運(yùn)行此方法時(shí)都將 selectedDate 設(shè)置為。所以它總是以今天為基礎(chǔ)倒退一個(gè)月。


您需要保持 selectedDate 的狀態(tài),這樣的事情應(yīng)該有效:


data() {

  return {

    selectedDate: undefined

  }

},

mounted() {

  this.selectedDate = moment(new Date())

},

methods: {

  prevMonth() {

    let futureMonth = moment(this.selectedDate.subtract(1, 'month')).startOf('month')

    this.selectedDate = futureMonth;

    ......

    })

  }

}


查看完整回答
反對(duì) 回復(fù) 2023-03-03
  • 1 回答
  • 0 關(guān)注
  • 148 瀏覽
慕課專欄
更多

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)