A
A
alaskafx2021-10-16 13:31:41
Vue.js
alaskafx, 2021-10-16 13:31:41

How to work in Vue in computed with setters?

I’ll say right away: I read the documentation, but I didn’t fully understand it ..

So ..
Imagine that I have a computer:

selectedCarNumber: {
            get: function () {
                return 0
            },
            set: function (value) {
                // что писать, чтобы поменять значение у возвращаемого числа get ?
            }
        },


How is the setter supposed to work?
Something like: and if I want to change the value of the returned number from get - how to be?

Please explain

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexey Yarkov, 2021-10-16
@alaskafx

data() {
  return {
    number: 0
  };
},
selectedCarNumber: {
            get: function () {
                return this.number;
            },
            set: function (value) {
                this.number = value;
            }
        },

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question