如何不点击input框也能通过js来让input获取到焦点?如何设置focus?
初次进入页面时会弹出软键盘,收起软键盘之后,怎么再次调起软键盘?
页面中的input写法为:
< input class = "input-code" type = "number" focus = "{{focus}}" @ input = "inputCodes" maxlength = "6" ></ input > |
给页面中的某view元素添加点击事件:
< view class = "cont" @ tap = "openKeyboard" ></ view > |
openKeyboard点击事件的内容:
openKeyboard() { this .focus = true ; } |
在data中设置变量focus,默认为true,用来控制input的获取焦点:
data = { focus: true } |
想要通过点击view触发openKeyboard事件来让input获取焦点,从而调起软键盘,可是input并没有获取到焦点,页面也没有弹出软键盘,点击其他元素都不起作用,只有点击input才能再次调起软键盘
期间,试过给input设置value值:
< input class = "input-code" type = "number" focus = "{{focus}}" value = "inputValue" @ input = "inputCodes" maxlength = "6" ></ input > |
给input添加adjust-position="true"和confirm-type="done"还是没起作用
请教各位