3
I am receiving a database coded string 64 from the database and I want it to render as an image on the screen, my question is:
Just set up the :src=
with the variable that contains the string Base64 or needs some treatment before assigning to the :src=
??
<template>
<q-layout>
<q-toolbar color="light-blue-10">
<q-toolbar-title>Webcam</q-toolbar-title>
</q-toolbar>
<webcam ref="webcam"></webcam>
<img :src="img" style="width: 640px;height: 480px;"/>
<q-btn color="light-blue-10" @click="photo">
<q-icon name="photo camera" />Capturar
</q-btn>
<q-btn color="light-blue-10" @click="enviar"><q-icon
name="send"/>Enviar Foto</q-btn>
<q-btn color="light-blue-10" @click="verFoto"><q-icon
name="person"/>Buscar Foto</q-btn>
<img :src="imagem" style="width: 640px; height: 480px;"/>
</q-layout>
</template>
<script>
import {
QLayout,
QToolbar,
QToolbarTitle,
QBtn,
QIcon
} from 'quasar'
import Webcam from 'vue-web-cam/src/webcam.vue'
import axios from 'axios'
export default {
components: {
QLayout,
QToolbar,
QToolbarTitle,
Webcam,
QBtn,
QIcon
},
data () {
return {
img: null,
imagem: null
}
},
methods: {
photo () {
this.img = this.$refs.webcam.capture()
},
enviar () {
let foto = this.img
console.log(foto)
axios({
method: 'post',
url: '/server/foto',
params: foto
}).then((response) => {
console.log(response.data)
})
},
verFoto () {
let self = this
axios({
method: 'post',
url: '/server/verfoto',
params: 'foto'
}).then((response) => {
console.log(response)
self.imagem = response.data[0]
})
}
}
}
Theoretically, just put the variable. It depends on how the image is coming to you, but at first, just replace the variable.
– Sergio
That’s what I did, I fetched the string from Mongo and put it in an array, then sent it to the client in the Answer request and only assigned the variable of the desired position of the array. Formulate an answer so that I can accept and that people who also have this doubt can clarify it here... Thank you very much for your help
– LeonardoEbert