因為在input標簽用了type="number", 導致報錯;
說明:從chrome 33版本開始, chrome瀏覽器只支持獲取type為text, search, URL, tel and password的input元素的selectionStart, selectionEnd 和 setSelectionRange 屬性, 在其余類型中嘗試獲取這些屬性chrome會提示錯誤。
解決方法:
在node_modules中找到fastclick.js文件
將大約在329行的內容:
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();
}