# uploadImgFileToMas ^5.2.0

图片上传接口,走Mas网络,需要app端在参数中添加通用参数

# 请求参数

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 {} 需要原生填充给服务器的post表单
fileKey String Y file 原生在post表单中传输图片文件的key值

# 接口调用示例


this.$bridge
    .uploadImgFileToMas(params)
    .then(res => {    
    this.$alert(res)
    })
    .catch(err => {
    this.$toast(err)
    })
// bridge v0.2.3起支持回调函数,回调函数可触发多次
this.$bridge
    .uploadImgFileToMas(
        params,
        res => {    
            this.$alert(res)
        },
        err => {
            this.$toast(err)
        }
    )
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20

# 返回参数

  • 成功时返回
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 错误消息(如有)
Last Updated: 10/27/2022, 4:12:24 PM