forked from opentiny/tiny-vue
fix(time-picker): fix time-picker components bug (#1461)
This commit is contained in:
parent
28a67f7507
commit
e48aacede9
|
@ -48,6 +48,9 @@ export const decrease =
|
|||
export const modifyDateField =
|
||||
({ emit, props, state }) =>
|
||||
(type, value) => {
|
||||
if (state[type] === value) {
|
||||
return
|
||||
}
|
||||
switch (type) {
|
||||
case 'hours':
|
||||
emit('change', modifyTime(props.date, value, state.minutes, state.seconds))
|
||||
|
|
|
@ -78,7 +78,7 @@ const initState = ({ reactive, computed, props, api }) => {
|
|||
return state
|
||||
}
|
||||
|
||||
export const renderless = (props, { computed, onMounted, reactive, watch }, { emit, vm, constants }) => {
|
||||
export const renderless = (props, { computed, onMounted, reactive, watch, nextTick }, { emit, vm, constants }) => {
|
||||
const api = {}
|
||||
const state = initState({ reactive, computed, props, api })
|
||||
|
||||
|
@ -108,13 +108,14 @@ export const renderless = (props, { computed, onMounted, reactive, watch }, { em
|
|||
})
|
||||
|
||||
watch(
|
||||
() => props.date.getTime(),
|
||||
() => props.date,
|
||||
() => {
|
||||
const timeType = ['hours', 'minutes', 'seconds']
|
||||
|
||||
timeType.forEach((type) => {
|
||||
api.modifyDateField(type, Math.round(state[type] / state.step[type]) * state.step[type])
|
||||
})
|
||||
nextTick(api.adjustSpinners)
|
||||
},
|
||||
{ immediate: true }
|
||||
)
|
||||
|
|
Loading…
Reference in New Issue