-
Notifications
You must be signed in to change notification settings - Fork 18
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
Cannot get the camera reference #18
Comments
Hello, Since you are using the setup tag, refs can only be used in onMounted like so: <script setup> import { ref } from "vue"; const camera = ref(null); onMounted(() => { // use ref }) async function capture() { console.log("Click"); } </script>Edit: apparently code blocks do not work on mobile... |
I tried <script setup>
import { onMounted, ref } from "vue";
let camera
async function capture() {
console.log("Click");
}
onMounted(() => {
camera = ref()
})
</script>
<template>
<camera autoplay ref="camera" />
<v-btn @click="capture">Snapshot!</v-btn>
</template> but I'm still getting the warning. Actually it seems that everytime I use Edit: I'm not expert or anything, but maybe a |
I've found myself with this same issue and it apparently lies in having the same name as the component for the reference, so simply changing the ref name worked for me: <script setup>
import { ref } from "vue";
const cameraObject = ref(null);
async function capture() {
cameraObject.value.snapshot...
console.log("Click");
}
</script>
<template>
<camera autoplay ref="cameraObject" />
<v-btn @click="capture">Snapshot!</v-btn>
</template> |
Hello!
I'm trying to use this component to capture images, but when I try to do this:
I keep getting this warning:
Am I doing something wrong?
The text was updated successfully, but these errors were encountered: