Vue + elementUi验证表单的input输入的是空格问题

<el-input v-model="form.reason" type="textarea" placeholder="请输入理由"/>
this.form.reason.split(' ').join('').length === 0

this.form.reason.split(' ').join('').length === 0的意思是先以空格拆分成数组,再拼接起来,最后判断字符串的长度,如果长度为0证明输入的全是空格

发布了144 篇原创文章 · 获赞 25 · 访问量 5万+

猜你喜欢

转载自blog.csdn.net/AdminGuan/article/details/103679013