# uploadImgFile ^5.0.0
上传图片文件,调用一次,上传一份图片文件
# 请求参数
Prop | Type | Required | Default | Description |
---|---|---|---|---|
param | Object | Y | {}附表1 | 请求参数 |
- 附表1:
param
参数
Prop | Type | Required | Default | Description |
---|---|---|---|---|
path | String | Y | N/A | 图片在手机中的路径 |
url | String | Y | N/A | 服务器上传图片的url |
maxWidth | String | Y | N/A | 图片最大宽度(如果不设置,则使用图片宽度) |
maxHeight | String | Y | N/A | 图片最大高度(如果不设置,则使用图片高度) |
compressRage | Number | Y | 100 | 图片的压缩率,范围为0~100,数值越高保真率越高100 不压缩压缩后的图片文件格式,固定为jpg 格式 |
netParam | Object | Y | {}附表1 | 需要原生填充给服务器的post表单 |
fileKey | String | Y | file | 原生在post表单中传输图片文件的key值 |
# 接口调用示例
this.$bridge
.uploadImgFile()
.then(res => {
this.$alert(res)
})
.catch(err => {
this.$toast(err)
})
1
2
3
4
5
6
7
8
9
2
3
4
5
6
7
8
9
# 返回参数
- 成功时返回
Prop | Type | Default | Description |
---|---|---|---|
progress | Number | 0 ~100 | 上传进度 |
msg | String | N/A | 获取到服务器返回的消息内容 |
- 失败时返回
Prop | Type | Default | Description |
---|---|---|---|
errorCode | Number | N/A | 上传失败后,服务器返回的错误码,例如404 |
errorMessage | String | N/A | 错误消息(如有) |