- //验证只可以输入数字和换行
"输入码"> - "form-conten">
-
- type="textarea"
- :rows="5"
- v-model="list"
- placeholder="请输入,多个用换行隔开"
- onkeyup="value=value.replace(/[^\d\n]/g,'')"
- @input="status"
- >
- "el-input__count" >最多同时录入10个,已录入{{ num }};
-
- //js
- status() {
- if (this.list) {
- if (this.num > 10) {
- this.list = this.list.slice(
- 0,
- this.num- 1
- );
- }
- this.num = this.list.length;
- const arr = this.list.split("\n");
- let str = "";
- arr.forEach((el) => {
- if (el) {
- str += "," + el;
- }
- });
- this.num = str.slice(1).split(",").length;
- }
- }
-
- //css
- .form-conten {
- position: relative;
- .el-input__count {
- color: #A8A8A8;
- position: absolute;
- right: 10px;
- bottom: 0;
- }
- }