阿里云图片压缩(文档:https://help.aliyun.com/document_detail/44688.html?spm=a2c4g.144582.0.i0)
两种封装方法:
/**图片大小尺寸格式化*/
Vue.filter("imageFormat", (val) => {
// return `${val}?x-oss-process=image/format,jpg/quality,q_70`
return `${val}?x-oss-process=image/format,jpg/resize,w_500,h_500/quality,q_100`
})
computed:{
formatImage() {
return val => {
if(val.includes('aliyuncs.com')) {
return `${val}?x-oss-process=image/format,jpg/resize,w_500,h_500/quality,q_100`
} else {
return val
}
}
},
},
用法:
1.:src=imgSrc | imageFormat
2.:src= formatImage(imgSrc)
拼接参数配置
resize:指定宽高缩放
quality:指定图片质量