index.wxml
<view>{{currentMonth}}月总预算</view>
index.js
Page({
data: {
currentMonth: ""
},
onLoad() {
// 获取当前月(注意:返回数值为0~11,需要自己+1来显示)
let currentMonth = new Date().getMonth() + 1;
// 补零
currentMonth = (currentMonth < 10 ? '0' : '') + currentMonth
this.setData({ currentMonth })
},
})