The input element's type ('number') does not support selection

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://segmentfault.com/a/1190000016275164
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞