Input type=number gets focus and reports an error

use tags on vue pages

 <input type="number" min="0" max="5000" v-model="choosePayDef" placeholder="">

Click this input box on the page and you will report an error

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

how to solve this problem?

Aug.16,2021

Hello, landlord! This problem can be explained on MDN . Portal , stackoverflow answer

Please note that, according to the WHATWG forms spec forms specification, starting with version 33 of chrome, chrome browsers only support getting the selectionStart, selectionEnd and setSelectionRange attributes of input elements whose type is text, search, URL, tel and password, and an attempt to get these attributes chrome in the rest of the types will prompt an error. For example, when you try to do this on < input type= "number" >, the chrome browser prompts the following error message: "Failed to read the 'selectionStart' property from' HTMLInputElement': The input element's type ('number') does not support selection." Related links: question on StackOverflow, whatwg bug, Chromium bug.
< hr >

if it is helpful, please click to adopt it, thank you ~

Menu