2

I am building controllers for sets of items. I am currently create a Javascript object, complete with functions and storing it in the data of the Vue instance. I am then passing this object like: <dynamic-table :table-object="objTable"></dynamic-table>

I am wondering if this is passed by reference or is it making a deep copy of the object every time the view is rendered.

I know VueEx might be a better solution but I am not able to use NodeJS for this project.

2
  • Vuex doesn't need Node.js. Where'd you get that idea? Use the "direct download" version on vuex.vuejs.org/en/installation.html. Commented Mar 8, 2018 at 17:45
  • ahh good to know (y), but initial question still stands. Commented Mar 8, 2018 at 18:03

1 Answer 1

2

The object is passed by reference. You can make a deep copy of the object inside the <dynamic-table>-component as follows:

data() {
    return {
      tableObject: JSON.parse(JSON.stringify(this.tableObj)),
    };
},
Sign up to request clarification or add additional context in comments.

1 Comment

Perfect, I was worried that doing things this way might have a horrible unseen complexity.

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.