上传文件组件 修改提示语

This commit is contained in:
zyn
2023-11-10 10:59:44 +08:00
parent 496c21a857
commit f0063727f8
2 changed files with 12 additions and 4 deletions
+6 -2
View File
@@ -323,12 +323,16 @@ export default {
fileSuffix = fileSuffix.toLocaleLowerCase()
// 判断上传文件格式
if (!this.allowType.includes(fileSuffix)) {
this.$message.error(`文件${file.name}格式不正确,请上传${this.allowType.join('、')}文件`)
this.$message({
dangerouslyUseHTMLString: true,
message: <div style="word-break: break-all;;color: #F56C6C">文件{file.name}格式不正确请上传{this.allowType.join('、')}文件</div>,
type: 'error'
})
return false
}
// 判断文件上传大小
if (file.size / 1024 / 1024 > this.size) {// eslint-disable-line
this.$message.error('文件' + file.name + `大小不超过${ this.size }M`)
this.$message.error('文件' + file.name + `超过${ this.size }M`)
return false
}
return true
@@ -123,12 +123,16 @@ export default {
const acceptArr = this.accept.split(',').map(type => type.slice(type.lastIndexOf('.') + 1))
// 判断上传文件格式
if (!acceptArr.includes(fileSuffix)) {
this.$message.error(`文件${file.name}格式不正确,请上传${acceptArr.join('、')}文件`)
this.$message({
dangerouslyUseHTMLString: true,
message: <div style="word-break: break-all;;color: #F56C6C">文件{file.name}格式不正确请上传{this.allowType.join('、')}文件</div>,
type: 'error'
})
return false
}
// 判断文件上传大小
if (file.size / 1024 / 1024 > this.size) {// eslint-disable-line
this.$message.error('文件' + file.name + `大小不超过${ this.size }M`)
this.$message.error('文件' + file.name + `超过${ this.size }M`)
return false
}
return true