-
Notifications
You must be signed in to change notification settings - Fork 135
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
issue: getting canvas in composition api with <script setup> #263
Comments
@peterfoers , pie in the sky, but try to rename
It looks, that it conflicts with the import of |
@peterfoers, any news? |
Hi @Norserium i have the same issue, <Cropper
ref="cropperComponent"
class="cropper"
:src="newImageDataUrl"
:debounce="false"
:stencil-props="{
aspectRatio,
}"
@change="onChange"
/> with const cropperComponent = ref<any>(null)
const retreiveCroppedImage = async () => {
console.log('cropperComponent.value', cropperComponent.value) // this log the correct vue instance
// Fail here because cropper is not defined
const { caneva } = cropperComponent.value.cropper.getResult()
emits('updated:image', caneva.toDataURL())
} I logged cropperComponent.value and found out i can access cropperComponent.value.getResult() and then this work: const retreiveCroppedImage = async () => {
console.log('cropperComponent.value', cropperComponent.value)
const { canvas } = cropperComponent.value.getResult()
console.log('result', result)
emits('updated:image', canvas.toDataURL())
} Something with composition api / script setup ? |
@unpseudocomplique, what's error did you get? |
Same here, using the composition api. With the code below I get "Canvas is undefined or null"
The console.log(result) which is logging the result of cropperRef.value.getResult() returns an object, which doesn't include the canvas
EDIT - I fixed it by setting :canvas="true" on the component |
Hi there! this is my change
this is my cropper
` christianbeecham In previews answer said that adding :canvas="true" helped, but in my situation is not working, so thanks in advance! EDIT: canvas.toBlob((blob) => { |
I'm trying to get the result of my crop in my setup function. According to the docs, this is the way in options API
const { coordinates, canvas, } = this.$refs.cropper.getResult();
. The composition way of doing this is like so:For the Cropper I get many warnings:
Component is missing template or render function
,Invalid vnode type when creating vnode: null.
Over and over again. And the Component doesn't render.It works without the syntactic sugar:
Any help is greatly appreciated.
The text was updated successfully, but these errors were encountered: