Home > database >  how to remove this.$set when migration from vue2 to vue3
how to remove this.$set when migration from vue2 to vue3

Time:10-21

I am doing migration from vue2 to vue3 and I need to remove $set as required.

So for example, in my application my code is like this in vue2:

this.$set(..., ..., null);

So to delete it should I use additional package like tiny-emitter and apply it like this?

emitter.set(..., ..., null);

How can I remove $set from my application for vue3?

CodePudding user response:

You don't need vue Set anymore because reactivity is now work fine in Vue3.

So to replace this.$set for an array you can juste do that:

// Old vue2 -> this.$set(array, index, null);
this.array[index] = null

So in each use you have, you just need to do the basic JS you need, and do not care about reactivity issue :).

  • Related