Hi there , I was learning vue js now and i was playing around with hover effect.
I tried to change the Src attribute of image when mouse was hovered.
the HTML tag was like this
I will try with watch method , but according to the documentation the methods runs every time a variable defined in the data object in the instance . Then why doesn’t it run when hover changes . I also tried it with computed why didn’t it work , computed should watch the related variables right?
I appreciate your solution and i think i am so near to grasping it , please clarify a little bit of my confusion. I was told that functions in the method object executes every time a variable changes and the DOM gets re-renderd. While computed functions will execute only if the dependency inside of the function is changed.
var vm = new Vue({
el: ‘.top_container’,
data: {
hover: false,
btn_img: “https://i.imgur.com/2RJTr2f.png”
},
methods: {
btn_changer: function() {
if (this.hover) {