How to change image on mouseover in vue.js? -
in vue.js, can bind image img element:
<img v-bind:src="myimage" />
how can define image displayed when mouse moves on image?
change value of myimage
in mouseover
listener:
new vue({ el: '#app', data() { return { myimage: "https://s-media-cache-ak0.pinimg.com/originals/bd/5d/84/bd5d845c980508d41b0329dc21d08d2b.jpg", otherimage: "https://cdn.pixabay.com/photo/2014/03/29/09/17/cat-300572_960_720.jpg" } } });
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.4.2/vue.min.js"></script> <div id="app"> <img :src="myimage" @mouseover="myimage = otherimage"/> </div>
Comments
Post a Comment