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 =
|
export const modifyDateField =
|
||||||
({ emit, props, state }) =>
|
({ emit, props, state }) =>
|
||||||
(type, value) => {
|
(type, value) => {
|
||||||
|
if (state[type] === value) {
|
||||||
|
return
|
||||||
|
}
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case 'hours':
|
case 'hours':
|
||||||
emit('change', modifyTime(props.date, value, state.minutes, state.seconds))
|
emit('change', modifyTime(props.date, value, state.minutes, state.seconds))
|
||||||
|
|
|
@ -78,7 +78,7 @@ const initState = ({ reactive, computed, props, api }) => {
|
||||||
return state
|
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 api = {}
|
||||||
const state = initState({ reactive, computed, props, api })
|
const state = initState({ reactive, computed, props, api })
|
||||||
|
|
||||||
|
@ -108,13 +108,14 @@ export const renderless = (props, { computed, onMounted, reactive, watch }, { em
|
||||||
})
|
})
|
||||||
|
|
||||||
watch(
|
watch(
|
||||||
() => props.date.getTime(),
|
() => props.date,
|
||||||
() => {
|
() => {
|
||||||
const timeType = ['hours', 'minutes', 'seconds']
|
const timeType = ['hours', 'minutes', 'seconds']
|
||||||
|
|
||||||
timeType.forEach((type) => {
|
timeType.forEach((type) => {
|
||||||
api.modifyDateField(type, Math.round(state[type] / state.step[type]) * state.step[type])
|
api.modifyDateField(type, Math.round(state[type] / state.step[type]) * state.step[type])
|
||||||
})
|
})
|
||||||
|
nextTick(api.adjustSpinners)
|
||||||
},
|
},
|
||||||
{ immediate: true }
|
{ immediate: true }
|
||||||
)
|
)
|
||||||
|
|
Loading…
Reference in New Issue