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>
Source:stackexchange.com