0

I have a component with empty data array

data: () => ({
    selectedResource : [],
}),

but when i try to add some item to this array i got an error

    selectResource(resource){
        console.log(this.selectedResource);
        this.selectedResource.append(resource)
    }

this.selectedResource.append is not a function

Viktor
  • 1,532
  • 6
  • 22
  • 61

2 Answers2

0

Using this should work

    data() {
        return {
            selectedResource: [],
        }
    },
musicvicious
  • 1,043
  • 16
  • 21
0

You can use $set for add item to array:

this.$set(yourArray, 'yourIndex', 'YourValue')
Simas Joneliunas
  • 2,890
  • 20
  • 28
  • 35
Pedram
  • 1
  • 1