0

I have a mixins variable known as imageUrl which I want to pass in image tag directly can someone tell me how to do that I have tried via :src="mixins_name" but it did not work

Bhumit 070
  • 416
  • 4
  • 12

1 Answers1

0

You need to set the mixin variable inside data. Then inherit the mixin. Codesandbox example for importing from another file.

var mixin = {
  data: function() {
    return {
      imgURL: "https://picsum.photos/200/200",
    }
  }
}

new Vue({
  mixins: [mixin],
  el: "#app"
})
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.5.17/vue.js"></script>
<div id="app">
  <img :src="imgURL" />
</div>
tuhin47
  • 5,172
  • 4
  • 19
  • 29