Blame view
src/views/components-demo/avatar-upload.vue
1.41 KB
d7d9c38c2 auto commit the c... |
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 |
<template> <div class="components-container"> <aside>This is based on <a class="link-type" href="//github.com/dai-siki/vue-image-crop-upload"> vue-image-crop-upload</a>. {{ $t('components.imageUploadTips') }} </aside> <pan-thumb :image="image" /> <el-button type="primary" icon="el-icon-upload" style="position: absolute;bottom: 15px;margin-left: 40px;" @click="imagecropperShow=true"> Change Avatar </el-button> <image-cropper v-show="imagecropperShow" :key="imagecropperKey" :width="300" :height="300" url="https://httpbin.org/post" lang-type="en" @close="close" @crop-upload-success="cropSuccess" /> </div> </template> <script> import ImageCropper from '@/components/ImageCropper' import PanThumb from '@/components/PanThumb' export default { name: 'AvatarUploadDemo', components: { ImageCropper, PanThumb }, data() { return { imagecropperShow: false, imagecropperKey: 0, image: 'https://wpimg.wallstcn.com/577965b9-bb9e-4e02-9f0c-095b41417191' } }, methods: { cropSuccess(resData) { this.imagecropperShow = false this.imagecropperKey = this.imagecropperKey + 1 this.image = resData.files.avatar }, close() { this.imagecropperShow = false } } } </script> <style scoped> .avatar{ width: 200px; height: 200px; border-radius: 50%; } </style> |