V
V
VladiGG2021-04-04 12:03:58
Vue.js
VladiGG, 2021-04-04 12:03:58

How to trigger reactivity when repeating the same primitive value?

Let's say I have a page primitive with a value of 1.

export default {
  data() {
  return {
    page: 1
}
},
watch: {
page(val) {
console.log(val)
}
},
methods: {
setPage() {
this.page = 1;
}
}
}


As you can see, the variable is set to the same value. In this case, watch is not triggered. My question is: how to set the same variable value and at the same time trigger watch, preferably without crutches a la (this.page=0; this.page=1) or new Number

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question