let flag = false
for (let i of this.list) {
let rex = new RegExp("^[ ]+$")
console.log('content', i.content)
console.log('content.length', i.content.length)
console.log('rex.test(content)', rex.test(i.content));
if ((!i.content) || (rex.test(i.content))) {
flag = true
break
}
}
if (flag) {
this.$message.error(`输入内容不能为空!`)
return
}
输入多个空格:
打印结果: