Skip to content

Instantly share code, notes, and snippets.

@F5F5
Created May 20, 2020 07:21
Show Gist options
  • Save F5F5/ae5456911133d13e275307de5f176c6f to your computer and use it in GitHub Desktop.
Save F5F5/ae5456911133d13e275307de5f176c6f to your computer and use it in GitHub Desktop.
VantWeapp datetime-picker Bug Report
// pages/test/test.js
Page({
/**
* 页面的初始数据
*/
data: {
currentDate: 1296576000000,
maxDate: 1296576000000,
minDate: 1259683200000,
month: '201102',
formatter (type, value) {
if (type === 'year') {
return `${value}年`
} else if (type === 'month') {
return `${value}月`
}
return value
}
},
monthChange (e) {
const t = new Date(e.detail)
const y = t.getFullYear()
let m = t.getMonth() + 1
m = m < 10 ? `0${m}` : m
const month = `${y}${m}`
this.setData({ month })
console.log(month)
},
monthMenuClose (e) {
},
onInput (event) {
console.error('onInput', event)
this.setData({
currentDate: event.detail
})
}
})
{
"navigationBarTitleText": "test",
"usingComponents": {
"van-datetime-picker":"@vant/weapp/datetime-picker"
}
}
<view>
<van-datetime-picker
class="picker"
value="{{currentDate}}"
type="year-month"
min-date="{{ minDate }}"
max-date="{{ maxDate }}"
formatter="{{formatter}}"
bind:input="onInput"
bind:cancel="monthMenuClose"
bind:confirm="monthChange"
/>
</view>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment