Reputation: 30015
I have a Vue.js instance with its set of data
predefined at initialization time.
vm = new Vue ({
el: "#root",
data: {
x: 3
}
})
I need to add, in the course of the script, a new element in data
. It does not matter for me that it not reactive.
vm.y = 4
Is there an issue with such an action? Specifically, can this impact the Vue instance behaviour (beside the non-reactivity aspect for this member)?
Note: this update is done before sending data
elsewhere and it is just more convenient to update it on the fly without making an intermediate copy (which is certainly a possibility, should the above update be somehow harmful)
Upvotes: 0
Views: 450
Reputation: 34306
Is there an issue with such an action? Specifically, can this impact the Vue instance behaviour (beside the non-reactivity aspect for this member)?
This is perfectly fine, it will not interfere with how the component works, nor will Vue delete the property at some point (or anything like that). The only pitfall is that the property will not be reactive.
Upvotes: 1