添加至本身的小程序方法github
極點日曆屬性接口文檔小程序
代碼實例:xss
xml:this
<calendar calendar-style="calendar" header-style="calendar-header" board-style="calendar-board" days-color="{{dayStyle}}" weeks-type="cn" binddayClick="dayClick" />
wxss:spa
/* 日曆 */ .calendar { background-color:white; padding-top: 10px; } .calendar-header{ font-size: large; color: #59518d; } .calendar-board{ color: #c7cbe2; font-weight: bold; }
js:code
Page({ /** * 頁面的初始數據 */ data: { dayStyle: [ { month: 'current', day: new Date().getDate(), color: 'white', background: '#AAD4F5' }, { month: 'current', day: new Date().getDate(), color: 'white', background: '#AAD4F5' } ], }, //給點擊的日期設置一個背景顏色 dayClick: function (event) { let clickDay = event.detail.day; let changeDay = `dayStyle[1].day`; let changeBg = `dayStyle[1].background`; this.setData({ [changeDay]: clickDay, [changeBg]: "#84e7d0" }) }, onLoad:function(){ } })
duang~~顯示結果以下 :xml