美文网首页
vue H5 项目中,点击input框第一次点击无效问题

vue H5 项目中,点击input框第一次点击无效问题

作者: IssunRadiance | 来源:发表于2021-04-07 16:08 被阅读0次

在最近的项目中,发现input输入框 在苹果手机上 点击失效, 需要多次点击才能获取焦点问题,是因为引入了FastClick的问题

解决:

FastClick.prototype.focus = function (targetElement) {

  let length;

  if (targetElement.setSelectionRange && targetElement.type.indexOf('date') !== 0 && targetElement.type !== 'time' && targetElement.type !== 'month') {

    length = targetElement.value.length;

    targetElement.focus();

    targetElement.setSelectionRange(length, length);

  } else {

    targetElement.focus();

  }

};

相关文章

网友评论

      本文标题:vue H5 项目中,点击input框第一次点击无效问题

      本文链接:https://www.haomeiwen.com/subject/ugsukltx.html