Vue.directive('focus', {
// 当绑定元素插入到 DOM 中。
inserted: function (el) {
// 聚焦元素
el.focus()
}
})
<input type="text" v-focus>
我想大声告诉你2017-07-06 10:38:42
According to this page, autofocus is not supported in iphone/ipad for usability reasons.
According to this article autofocus
or el.focus()
Due to user experience issues, Apple does not allow it to be used on iPhone/iPad. Because focus
may cause the page to zoom, open the page, and suddenly zoom, the experience is too bad, and the Big Apple can't stand it.