diff --git a/frontent/ops_vue_js/src/components/imageCropper.vue b/frontent/ops_vue_js/src/components/imageCropper.vue index 4e0e708..c1b0046 100644 --- a/frontent/ops_vue_js/src/components/imageCropper.vue +++ b/frontent/ops_vue_js/src/components/imageCropper.vue @@ -4,61 +4,108 @@ import { onMounted, ref } from "vue"; import "cropperjs"; -const cro_sele=ref() -const cro_canv=ref() +const cro_sele = ref(); +const cro_canv = ref(); +const cro_imag = ref(); -var cor_size_width=400 -var cor_size_height=400 +var cor_size_width = 300; +var cor_size_height = 300; + +const is_have_URL = ref(false); + +const reader = new FileReader(); +reader.onload = () => { + initCropper(reader.result); +}; onMounted(() => { - cro_sele.value.$change(0,0,cor_size_width,cor_size_height) - cro_canv.value.style.width=cor_size_width.toString()+"px" - cro_canv.value.style.height=cor_size_height.toString()+"px" + cro_sele.value.$change(0, 0, cor_size_width, cor_size_height); + cro_canv.value.style.width = cor_size_width.toString() + "px"; + cro_canv.value.style.height = cor_size_height.toString() + "px"; + + cro_imag.value.src = "https://wnfed.com/usr/uploads/2020/07/736937178.jpg"; //console.log(cro_canv.value.clientHeight) }); -function getsele() {} +function initCropper(imageSrc){ + + is_have_URL.value = true; + cro_imag.value.src=imageSrc; +} + +function inputfile(e){ + const file = e.target.files[0]; + if (!file){ + e.target.value="" + is_have_URL.value = false; + return; + } + + if (!file.type.startsWith('image/')) { + e.target.value="" + is_have_URL.value = false; + return; + } + + reader.readAsDataURL(file); + + } + +function getsele() { + console.log(cro_canv.value.$toCanvas()) +}