-
Notifications
You must be signed in to change notification settings - Fork 36
/
hide-input.html
88 lines (82 loc) · 2.51 KB
/
hide-input.html
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1.0">
<title>cdn-cropper-simple</title>
<script src="https://cdn.jsdelivr.net/npm/vue@2.6.11/dist/vue.min.js"></script>
<script src="../../dist/index.js"></script>
<style>
.dome {
display: flex;
justify-content: space-between;
padding-left: 22px;
}
.cropper {
width: 80px;
height: 80px;
line-height: 80px;
/* 切记position: relative一点要有 */
position: relative;
border-radius: 80px;
overflow: hidden;
text-align: center;
}
.img {
position: absolute;
width: 100%;
height: 100%;
left: 0;
top: 0;
}
.info {
font-size: 18px;
height: 40px;
line-height: 40px;
margin-left: 30px;
flex: 1;
text-align: left;
}
</style>
</head>
<body>
<div class="dome" id="app">
<!-- <img :src="require('@/assets/logo.png')"></img> -->
<input type="file" name="img" @change="chnage">
<div class="cropper">
<img :src="img" class="img" />
<!-- option是配置,格式是对象,getbase64Data是组件的一个方法获取裁剪完的头像 -->
<h5-cropper ref="cropper" hide-input @getbase64="getbase64Data" @getblob="getBlob" @get-file="getFile"></h5-cropper>
</div>
<div class="info">
<div>作者:居里栈栈</div>
<div>Wechat:812936565</div>
</div>
</div>
<script>
new Vue({
el: '#app',
data: function() {
return {
img: "http://geren.yi-school.top/images/logo.png"
}
},
methods: {
chnage({target}){
this.$refs.cropper.loadFile(target.files[0])
target.value = ''
},
getbase64Data(data) {
this.img = data
},
getBlob(blob){
console.log(blob)
},
getFile(file) {
console.log(file)
}
}
})
</script>
</body>
</html>