Skip to content

Commit b2af2dd

Browse files
committed
refine avatarUpload demo
1 parent dfd7ce8 commit b2af2dd

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

src/components/ImageCropper/index.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -694,7 +694,7 @@
694694
// 上传成功
695695
function(resData) {
696696
that.loading = 2;
697-
that.$emit('crop-upload-success', url);
697+
that.$emit('crop-upload-success', resData);
698698
},
699699
// 上传失败
700700
function(sts) {

src/views/components/avatarUpload.vue

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,12 @@
44
由于我在使用时它只有vue@1版本,而且有些业务的需求耦合到七牛等等原因吧,自己改造了一下,如果大家要使用的话,优先还是使用官方component
55
</code>
66

7-
<PanThumb image='https://wpimg.wallstcn.com/577965b9-bb9e-4e02-9f0c-095b41417191'>
7+
<PanThumb :image='image'>
88
</PanThumb>
99
<el-button type="primary" icon="upload" style="position: absolute;bottom: 15px;margin-left: 40px;" @click="imagecropperShow=true">修改头像
1010
</el-button>
1111

12-
<ImageCropper :width="300" :height="300" url="https://httpbin.org/post" @crop-upload-success="cropSuccess" :key="imagecropperKey"
13-
v-show="imagecropperShow" />
12+
<ImageCropper :width="300" :height="300" url="https://httpbin.org/post" @crop-upload-success="cropSuccess" :key="imagecropperKey" v-show="imagecropperShow" />
1413
</div>
1514
</template>
1615
<script>
@@ -21,13 +20,15 @@
2120
data() {
2221
return {
2322
imagecropperShow: false,
24-
imagecropperKey: 0
23+
imagecropperKey: 0,
24+
image: 'https://wpimg.wallstcn.com/577965b9-bb9e-4e02-9f0c-095b41417191'
2525
}
2626
},
2727
methods: {
28-
cropSuccess() {
28+
cropSuccess(resData) {
2929
this.imagecropperShow = false;
3030
this.imagecropperKey = this.imagecropperKey + 1;
31+
this.image = resData.files.avatar;
3132
}
3233
}
3334
};

0 commit comments

Comments
 (0)