0

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)

1 Answer 1

1

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.