一、img预览框拿到blob图片信息
这里只有主要代码
<input type="file" hidden ref="inputFile" @change="updateImg" />
const file = this.$refs.inputFile.files[0]
// 拿到blob图片信息
this.img = window.URL.createObjectURL(file)
二、cropperjs使用
1、安装cropperjs
npm install cropperjs
2、引入css、js
import 'cropperjs/dist/cropper.css'
import Cropper from 'cropperjs'
3、在mounted中初始化
const image = this.$refs.img
const cropper = new Cropper(image, {
aspectRatio: 16