Vue.js: How can I update an array of objects?

Damon

I am trying to update an array of objects in Vue.js. When trying to update the values of my location I am struggling to update the objects within an array.

When I log the objects out, I get this:

console.log(this.location) // {…}

console.log(this.location.additionalProperties);  // [{…}, __ob__: Observer]

console.log(this.location.additionalProperties.integrations);  // undefined

My additionalProperties object looks like this:

"additionalProperties": [
    {
      "integrations": [
        {
           "foo": {
               "locationId": 123,
               "example": "bar",
               ...
           }
        }
      ]
    }
],

I am passing in my location as a props like this:

location: {
    type: Object,
    required: true,
    default: () => ({}),
},

I know I am getting the location passed in correctly. I believe it is a syntax issue I am struggling with. I am trying to set my foo object to be something like this:

this.location.additionalProperties.integrations.foo = {
   locationId: 456,
   example: "testing",
   somethingElse: "anotherValue"
}

Using the above, I'll get a version of cannot set foo of undefined. How can I update the object within the additionalProperties array?

Thank you for any suggestions!

Artur Tagisow

additionalProperties is an array

"additionalProperties": [
    {
      "integrations": [
        {
           "foo": {
               "locationId": 123,
               "example": "bar",
               ...
           }
        }
      ]
    }
],

this.location.additionalProperties[0].integrations.foo = ...

この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。

侵害の場合は、連絡してください[email protected]

編集
0

コメントを追加

0

関連記事

分類Dev

How can I display an array of objects?

分類Dev

How can I update Vue immediately after an axios call?

分類Dev

Javascript: How can I swap elements of an array of objects (by reference, not index)?

分類Dev

How can I use FormGroup with an array of objects in Angular

分類Dev

How can I find many sums in an array of objects

分類Dev

How can I update Node.JS through JXCore?

分類Dev

How can i change components data in Vue.js?

分類Dev

Vue - how can i load CSS and JS files in a component?

分類Dev

How can I convert an array of arrays to an array of objects, selecting the key from other array?

分類Dev

Javascript - filtering a list: how can I find an intersection between an array with objects including array and an array?

分類Dev

How can I get a new array filtered by value in another array of objects? javascript

分類Dev

How can I slice out all of the array objects containing a value and storing them in a new array

分類Dev

How to create MongoDB Update query to update certain elements in an array of objects

分類Dev

How can I update a table that has struct inside a struct and both structs are inside an array? ARRAY<STRUCT<STRUCT>>

分類Dev

vue.js: how to update state with object?

分類Dev

Why can't I make a copy of this 2d array in JS? How can I make a copy?

分類Dev

Why can't I make a copy of this 2d array in JS? How can I make a copy?

分類Dev

Ruby on Rails: How can I use JSONPath to access (and save to database) nested objects/properties within a JSON array?

分類Dev

How can I check if the array of objects has duplicate property values and get the last value that is repeated?

分類Dev

how to convert array of objects to one object i can obj.find() in

分類Dev

Mongodb update array of objects

分類Dev

How do I deploy REST API using an imported array of JS objects?

分類Dev

vue.js best way to update entire array

分類Dev

How can i iterate over the row and print the objects value in excel in node js?

分類Dev

How do i push objects into the same array?

分類Dev

How can i update an array of values to my modal through foreach in yii2

分類Dev

How can I create an interface for a collection of objects?

分類Dev

How can I write a collection of objects to file?

分類Dev

Show bootstrap alert with condition (Vue.js): how can I access this variable in order to change its value?

Related 関連記事

  1. 1

    How can I display an array of objects?

  2. 2

    How can I update Vue immediately after an axios call?

  3. 3

    Javascript: How can I swap elements of an array of objects (by reference, not index)?

  4. 4

    How can I use FormGroup with an array of objects in Angular

  5. 5

    How can I find many sums in an array of objects

  6. 6

    How can I update Node.JS through JXCore?

  7. 7

    How can i change components data in Vue.js?

  8. 8

    Vue - how can i load CSS and JS files in a component?

  9. 9

    How can I convert an array of arrays to an array of objects, selecting the key from other array?

  10. 10

    Javascript - filtering a list: how can I find an intersection between an array with objects including array and an array?

  11. 11

    How can I get a new array filtered by value in another array of objects? javascript

  12. 12

    How can I slice out all of the array objects containing a value and storing them in a new array

  13. 13

    How to create MongoDB Update query to update certain elements in an array of objects

  14. 14

    How can I update a table that has struct inside a struct and both structs are inside an array? ARRAY<STRUCT<STRUCT>>

  15. 15

    vue.js: how to update state with object?

  16. 16

    Why can't I make a copy of this 2d array in JS? How can I make a copy?

  17. 17

    Why can't I make a copy of this 2d array in JS? How can I make a copy?

  18. 18

    Ruby on Rails: How can I use JSONPath to access (and save to database) nested objects/properties within a JSON array?

  19. 19

    How can I check if the array of objects has duplicate property values and get the last value that is repeated?

  20. 20

    how to convert array of objects to one object i can obj.find() in

  21. 21

    Mongodb update array of objects

  22. 22

    How do I deploy REST API using an imported array of JS objects?

  23. 23

    vue.js best way to update entire array

  24. 24

    How can i iterate over the row and print the objects value in excel in node js?

  25. 25

    How do i push objects into the same array?

  26. 26

    How can i update an array of values to my modal through foreach in yii2

  27. 27

    How can I create an interface for a collection of objects?

  28. 28

    How can I write a collection of objects to file?

  29. 29

    Show bootstrap alert with condition (Vue.js): how can I access this variable in order to change its value?

ホットタグ

アーカイブ