Answer the question
In order to leave comments, you need to log in
Vue js how to manage src attribute value if it should be set by php script on page load?
<img src="<?=$imageUrl?>" >
and I want to change the value of the src attribute from the vue js application
v-attr does not work, v-bind cannot be applied.
I forgot to write right away, the image should be displayed normally with javascript disabled.
(We support the old android 2 browser, vuejs does not work in it).
Is there a normal solution?
Looks like no.
Came out like this:
<img ref="imagepreview" src="<?=$imageUrl?>" >
onUploadImage(sImageUrl) {
this.$refs.imagepreview.setAttribute('src', sImageUrl);
}
Answer the question
In order to leave comments, you need to log in
As an option, you can have an input in which to collect all the data that is given through PHP.
And already in Vue use this data
...
data() {
return {
dataFromPhp: null
}
}
...
created() {
this.dataFromPhp = JSON.parse(document.getElementById('input-data-to-vue'));
}
...
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question