<template>
<CropperImage ref="refCropper" :src="img" @cropend="handleCropend" style="width: 40vw" />
</template>
<script lang="ts">
import { defineComponent, ref } from 'vue';
import { CropperImage } from '/@/components/Cropper';
import img from '/@/assets/images/header.jpg';
export default defineComponent({
components: {
CropperImage,
},
setup() {
const info = ref('');
const cropperImg = ref('');
function handleCropend({ imgBase64, imgInfo }) {
info.value = imgInfo;
cropperImg.value = imgBase64;
}
return {
img,
info,
cropperImg,
handleCropend,
};
},
});
</script>
{
aspectRatio: 1,
zoomable: true,
zoomOnTouch: true,
zoomOnWheel: true,
cropBoxMovable: true,
cropBoxResizable: true,
toggleDragModeOnDblclick: true,
autoCrop: true,
background: true,
highlight: true,
center: true,
responsive: true,
restore: true,
checkCrossOrigin: true,
checkOrientation: true,
scalable: true,
modal: true,
guides: true,
movable: true,
rotatable: true,
}
<template>
<CropperAvatar :uploadApi="uploadApi" />
</template>
<script lang="ts">
import { defineComponent, ref } from 'vue';
import { CropperAvatar } from '/@/components/Cropper';
import { uploadApi } from '/@/api/sys/upload';
export default defineComponent({
components: {
CropperAvatar,
},
});
</script>