mirror of
https://github.com/PanJiaChen/vue-element-admin.git
synced 2025-08-10 12:01:57 +08:00
修改上传图片时只能使用默认名称的问题
上传图片时只能使用file指定的名称,而不能使用本地的文件名称
This commit is contained in:
parent
0caa975ee2
commit
3716590b2f
@ -225,6 +225,7 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
|
let fileName
|
||||||
const { imgFormat, langType, langExt, width, height } = this
|
const { imgFormat, langType, langExt, width, height } = this
|
||||||
let isSupported = true
|
let isSupported = true
|
||||||
const allowImgFormat = ['jpg', 'png']
|
const allowImgFormat = ['jpg', 'png']
|
||||||
@ -478,6 +479,7 @@ export default {
|
|||||||
},
|
},
|
||||||
// 设置图片源
|
// 设置图片源
|
||||||
setSourceImg(file) {
|
setSourceImg(file) {
|
||||||
|
this.fileName = file.name.substr(0,file.name.lastIndexOf('.'))
|
||||||
const fr = new FileReader()
|
const fr = new FileReader()
|
||||||
fr.onload = e => {
|
fr.onload = e => {
|
||||||
this.sourceImgUrl = fr.result
|
this.sourceImgUrl = fr.result
|
||||||
@ -773,7 +775,8 @@ export default {
|
|||||||
fmData.append(
|
fmData.append(
|
||||||
field,
|
field,
|
||||||
data2blob(createImgUrl, mime),
|
data2blob(createImgUrl, mime),
|
||||||
field + '.' + imgFormat
|
//field + '.' + imgFormat
|
||||||
|
this.fileName + '.' + imgFormat
|
||||||
)
|
)
|
||||||
// 添加其他参数
|
// 添加其他参数
|
||||||
if (typeof params === 'object' && params) {
|
if (typeof params === 'object' && params) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user