As using vue by clicking on the button to record the data in the src attribute of the picture?

As using vue by clicking on the button to record the data in the src attribute of the picture?
June 14th 19 at 20:31
1 answer
June 14th 19 at 20:33
Solution
Try this:
<img src="someUrl" ref="picture">
<button type="button" @click="getImageSrc()">Get source</button>

...
methods: {
 getImageSrc() {
 this.yourVariable = this.$refs.picture.getAttribute('src');
},
},
Thanks, but I was told that it is better to avoid ref) Can still somehow it is possible? - cade.Beier commented on June 14th 19 at 20:36
well a similar problem only through the ref to decide. Especially in such a simple task you ref, not exactly a fail, believe me. - webster_Boyer commented on June 14th 19 at 20:39
or as it is written , or the url is already known, since the template also generated in view and src somewhere con - odell commented on June 14th 19 at 20:42

Find more questions by tags Vue.js