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

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?

Upvotes: 2

Views: 942

Answers (2)

tesicg
tesicg

Reputation: 4053

Could you, please, tell how the following should be in Vue 3:

this.$set(this, 'model', this.entries[0])

I suppose it should be like this:

this.model = this.entries[0]

Upvotes: -1

Raphael Rlt
Raphael Rlt

Reputation: 588

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 :).

Upvotes: 4

Related Questions