资讯专栏INFORMATION COLUMN

The input element's type ('number')

CoderDock / 2041人阅读

fastclick.js?bf9a:331 Uncaught DOMException: Failed to execute "setSelectionRange" on "HTMLInputElement": The input element"s type ("number") does not support selection

解决方法:

找到node_module中的文件fastclick.js, line: 327 将

if (deviceIsIOS && targetElement.setSelectionRange && targetElement.type.indexOf("date") !== 0 && targetElement.type !== "time" && targetElement.type !== "month") {
            length = targetElement.value.length;
            targetElement.setSelectionRange(length, length);
        } else {
            targetElement.focus();
    }

替换为:

var useSelectionRange = deviceIsIOS;
    if(useSelectionRange){
        try{
            length = targetElement.value.length;
            targetElement.setSelectionRange(length, length);
        }catch(error){
            useSelectionRange = false;
        }
    }
    if (!useSelectionRange) {
        targetElement.focus();
    }

文章版权归作者所有,未经允许请勿转载,若此文章存在违规行为,您可以联系管理员删除。

转载请注明本文地址:https://www.ucloud.cn/yun/97397.html

相关文章

  • H5 input[type='date'] 优化 pc端和移动端的使用

    标签在HTML5中新增了color, date, datetime, datetime-local, month, week, time, email, number, range, search, tel 以及 url新属性。本篇记录在开发中使用date属性,遇到的一些问题,以及功能扩展: 获取当前日期,并显示在input[type=date]上 html: js: $(function(...

    VincentFF 评论0 收藏0
  • H5 input[type='date'] 优化 pc端和移动端的使用

    标签在HTML5中新增了color, date, datetime, datetime-local, month, week, time, email, number, range, search, tel 以及 url新属性。本篇记录在开发中使用date属性,遇到的一些问题,以及功能扩展: 获取当前日期,并显示在input[type=date]上 html: js: $(function(...

    wemallshop 评论0 收藏0
  • H5 input[type='date'] 优化 pc端和移动端的使用

    标签在HTML5中新增了color, date, datetime, datetime-local, month, week, time, email, number, range, search, tel 以及 url新属性。本篇记录在开发中使用date属性,遇到的一些问题,以及功能扩展: 获取当前日期,并显示在input[type=date]上 html: js: $(function(...

    haoguo 评论0 收藏0
  • the deadline of JavaScript's this

    摘要:在用处千千万,基于自己研究和认识,今天做一个了断。可以取所属对象的上下文的方法称为公共方法,可以使属性,方法变成公开的属性方法在构造函数,方法中用到。内部函数调用的时候,只能搜索到其活动对象为止,不可能直接访问外部函数中的变量。 this this在JavaScript用处千千万,基于自己研究和认识,今天做一个了断。 全局,匿名函数调用 对象方法调用 闭包总指向上一级 构造函数中,指...

    chinafgj 评论0 收藏0

发表评论

0条评论

最新活动
阅读需要支付1元查看
<