Home > Article > Web Front-end > How to set the length of the input box in vue.js
Vue.js method to set the length of the input box: use vue to control the input input length and obtain the length of the input content. The code is [436460562355b442b5fd5afa38d88e9c 11) value = value.slice】.
The operating environment of this tutorial: Windows 7 system, Vue version 2.9.6, Dell G3 computer.
[Recommended related articles: vue.js]
vue.js method of setting the length of the input box:
Log in during development today page, you need to set the length of the login input box. The input type is number
<input type="number" maxlength="11" placeholder="请输入手机号">
. It is found that when writing like this, the input length limit does not take effect. After testing, it is found that when the type is number or text, set The maxlength
parameter will not take effect.
vue controls the input input length and obtains the length of the input content
<input type="number" oninput="if(value.length > 11)value = value.slice(0, 11)" placeholder="请输入手机号" ref="passwords" v-model.number="passwords"> console.log(this.$refs.passWords.value.length);
Related learning recommendations: javascript video tutorial
The above is the detailed content of How to set the length of the input box in vue.js. For more information, please follow other related articles on the PHP Chinese website!