我制作了自己的时间选择器组件。我认为效果很好。但是我在Safari上遇到问题。这意味着我无法单击(负责鼠标输入)负责分钟值的输入。当inputHours被聚焦并按TAB时,我可以聚焦此字段。这是我的html文件:
<div class="timepicker-div">
<input
autocomplete="off"
class="timepicker-number-hours"
#inputHours
max="12"
min="1"
type="number"
(blur)="setValueOnBlur()"
(change)="restoreHour(inputHours)"
(click)="inputHours.select()"
(keydown)="disableLeftRightArrowKeys($event)"
(keypress)="checkHours(inputHours, $event)"
(paste)="$event.preventDefault()"/>
<span>:</span>
<input
autocomplete="off"
class="timepicker-number-minutes"
#inputMinutes
max="59"
min="0"
type="number"
(blur)="setValueOnBlur()"
(change)="parseMinutes(inputMinutes)"
(click)="inputMinutes.select()"
(keydown)="disableLeftRightArrowKeys($event)"
(keypress)="checkMinutes(inputMinutes, $event)"
(paste)="$event.preventDefault()"/>
<input
class="timepicker-meridian"
#inputMeridian
readonly
type="text"
(blur)="setValueOnBlur()"
(click)="changeMeridianValue(inputMeridian)"/>
<i class="icon-clock"></i></div>
您知道我该怎么做才能将输入内容集中在onClick上吗?我尝试了getElementById('id')。focus(),inputMinutes.focus(),但对我来说没有任何作用吗?