# compressImage ^6.8

图片压缩

# 请求参数

Prop Type Comment
src String 图片文件路径(相对路径)
quality Number 质量,0-100,默认值80
target String 压缩结果,图片文件路径

# 参数代码示例

    let params = {
        src: 'filename.txt',
        quality: 80,
        src: 'compress/test.jpg'
    }
1
2
3
4
5

# 接口调用示例

    let params = { src: this.src, quality: this.quality, target:this.target}   //压缩接口参数
    this.$bridge
        .compressImage(params)
        .then(res => {    
            this.$alert(res)
        })
        .catch(err => {
            this.$toast(err)
        })
1
2
3
4
5
6
7
8
9

# 返回参数

  • 成功时返回
Prop Type Value
code Number 0
msg String -
  • 失败时返回
Prop Type Value Comment
code Number -12 文件操作失败
msg String

# 返回示例


{
    "tempFilePath": "compress/test.jpg",
    "code": 0
}

1
2
3
4
5
6

# FAQ

tip

一次只能压缩一张图片

更新时间: 7/27/2021, 11:23:45 AM