代码:
//如果有值的话
if (data) {
// 去掉空格之后的长度是否是0?如果全部输入的空格,那就必须重写!
if (data.trim().length == 0) {
this.$message.error('请不要全部填写空格!!!')
} else {
this.$api
.xxx({
id: this.fileId,
info: data.trim()// 去除字符串的头尾空格
})
.then(res => {
//console.log('提交结果', res)
if (res.data.code == 200) {
this.$message.success('提交成功!!')
} else {
this.$message.error('失败!提交失败!')
}
})
.catch(() => {
})
}
} else {
this.$message.error('必须填写!!!')
}