Created
May 20, 2020 07:21
-
-
Save F5F5/ae5456911133d13e275307de5f176c6f to your computer and use it in GitHub Desktop.
VantWeapp datetime-picker Bug Report
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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 | |
}) | |
} | |
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"navigationBarTitleText": "test", | |
"usingComponents": { | |
"van-datetime-picker":"@vant/weapp/datetime-picker" | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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