-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
40 lines (38 loc) · 893 Bytes
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import Vue from 'vue'
import VueQuickCropper from './src/VueQuickCropper.vue'
Vue.component('quick-cropper', VueQuickCropper)
new Vue({
el: '#app',
data: {
imgSrc: "", // 图片数据
visible:false, // 剪切框展示
},
methods: {
// 获得头像的base64和二进制
finish(base64,data){
console.log(base64,'图片base64')
console.log(data,'图片二进制')
},
// 确定使用
confirm() {
this.$nextTick(() => {
this.$refs.cropper.confirm()
})
},
// 取消
cancel(){
this.visible = false
},
// 选择img回调
choiceImg(e) {
this.visible = true
const file = e.target.files[0]
const reader = new FileReader();
reader.readAsDataURL(file)
reader.onload = (e) => {
this.imgSrc = reader.result
this.$refs.cropper.init()
}
},
}
})