2

I did use Objects in Arrays to read and it always worked but somehow it won't work for initialzing them. I need more variables inside articleList then only the number, so i can't just give the value to a normal array.

This works:

data(){
        return{
            articleList:[],
      }
}

in the method {
  number.forEach((e,i)=>{
                        this.articleList[i] = e
                    })
}

This somehow won't work:

 data(){
            return{
                articleList:[
                    {artNr:null}
                    ],
}
}
 in the method{
 number.forEach((e,i)=>{
                        this.articleList[i].artNr = e
                    })
}

1 Answer 1

1

you should to merge you current object with the artNr property as below:

this.articleList[i] = {...this.articleList[i], artNr: e}

or

Object.assign(this.articleList[i], { artNr: e }) 
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.