M
M
Max Zhukov2017-10-03 13:47:52
Vue.js
Max Zhukov, 2017-10-03 13:47:52

How to write the src attribute of the image to data via vue on button click?

How to write the src attribute of the image to data via vue on button click?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
N
Nikita Velko, 2017-10-03
@MaksZhukov

Try like this:

<img src='someUrl' ref="picture">
<button type="button" @click="getImageSrc()">Get source</button>

...
methods: {
  getImageSrc() {
    this.yourVariable = this.$refs.picture.getAttribute('src');
  },
},

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question