Home > Web Front-end > Vue.js > body text

How to set the length of the input box in vue.js

coldplay.xixi
Release: 2023-01-13 00:44:50
Original
5450 people have browsed it

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 [

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="请输入手机号">
Copy after login

. 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);
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template