D
D
Dima2020-06-16 16:22:44
Vue.js
Dima, 2020-06-16 16:22:44

How to return a value?

there is such a code

<td v-for="md in monday"      @mousemove="mouseoverEvent($event, md.status )" :class="{red: md.status}"   :key="md.id" :data-hours="md.minutes"> </td>




 methods:{
            mouseoverEvent:function(event, status){
                if(event.which == 1){
                
                 return status=!status


                }
            }
        },


I want that from function the status was returned and the class changed. everything works ok if you write directly to the line , but how to return from the function for this particular td? @mousemove="md.status=!md.status"

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Aetae, 2020-06-16
Dolgoter @SpiderPigAndCat

Man, learn the basics.
Nothing is passed by reference to js, ​​a copy of the reference is made for objects, primitives are copied completely. statusinside mouseoverEventyou have a completely separate variable and a new primitive. Need to be transferred md.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question