search

Home  >  Q&A  >  body text

Vue.js data values ​​remain unchanged

I have a data called: cat_pressed

There is also this function that changes the data value:

changeCat(){
            this.cat_pressed === 'brauh'
}

But whenever I call the function the value doesn't change, I don't know why I've tried everything but nothing works.

P粉274161593P粉274161593235 days ago505

reply all(1)I'll reply

  • P粉523335026

    P粉5233350262024-04-04 07:56:06

    It looks like you accidentally used the wrong operator.

    Use

    === for checking equality - but you want the value to be assigned to cat_pressed, so you need =.

    changeCat(){
        this.cat_pressed = 'brauh'
    }

    reply
    0
  • Cancelreply