I have a crop function for Vue Advanced Cropper like this:
crop() {
const { canvas } = this.$refs.cropper.getResult();
if (canvas) {
const form = new FormData();
canvas.toBlob(blob => {
form.append('files[]', blob);
// Perhaps you should add the setting appropriate file format here
}, 'image/jpeg');
this.formData = form;
}
},
My HTML:
<div v-if="cropView">
<h1>Step 2: Crop images</h1>
<div class="upload-example__cropper-wrapper">
<div v-for="image in this.images" :key="image">
<cropper ref="cropper" class="upload-example__cropper"
check-orientation :src="image.src"/>
<button v-if="image.src" class="upload-example__button" @click="crop">Crop</button>
<!--<div class="upload-example__reset-button" title="Reset Image" @click="reset()"></div>-->
<div class="upload-example__file-type" v-if="image.type">
{{ image.type }}
</div>
</div>
</div>
</div>
I have included the import for Cropper:
import {Cropper} from 'vue-advanced-cropper'
Version from package.json:
"vue-advanced-cropper": "^2.8.1"
Everything works until I get to the crop function where it says the following:
Uncaught TypeError: this.$refs.cropper.getResult is not a function
My first thought was, that it may have something to due with looping through multiple images, however it does not work with juse one either. I have tried combining the part from disc and upload to server from here:
https://norserium.github.io/vue-advanced-cropper/guides/recipes.html#upload-image-to-a-server