[Vuejs]-How to initialize data in component according to the received props and don't lose reactivity

1👍

There are multiple problems

  1. In your examples you don’t show how you initialize your data() but assuming from the code this.markedSteps = []; in initializeMarkedSteps I think you have no markedSteps in data(). That’s problem number 1. Properties in data are only reactive if they existed when the instance was created (add markedSteps: [] into data())

  2. Due to limitations in JavaScript, Vue cannot detect changes to an array when you directly set an item with the index – use Vue.set(this.markedSteps, i, true) instead

Leave a comment