Skip to content

Latest commit

 

History

History
46 lines (35 loc) · 940 Bytes

vue图片上传及压缩组件的封装.md

File metadata and controls

46 lines (35 loc) · 940 Bytes

vue图片上传及压缩组件的封装

源码地址

使用方法:

先去上面的链接把组件,复制到自己的components文件夹内

1.先下载
cnpm install compressorjs --save-dev //压缩
2.引入组件
<script>
import uploadPictures from "../../components/uploadPictures";
export default {
  components: {
    uploadPictures
  },
},
</script>
3.用法
//emitType:自定义方法,接收从后端返回的图片码
//title:名字,身份证上传、银行卡上传,(需要则传、不需要不传)
<uploadPictures :openTitle="{emitType:'idCard',title:$t('m.openingInformation.HKPic')}"/>

//在mounted里面监听后端返回的码
 mounted() {
    this.judgeLogin();
      this.$on('idCard',msg=>{
      console.log(msg)
    })
       this.$on('addressCard',msg=>{
      console.log(msg)
    })
  }