K
K
koliane2019-09-29 23:21:57
JavaScript
koliane, 2019-09-29 23:21:57

How in vue.js, in the tsx component, display elements in a loop?

tsx components are used, i.e. function is used to render the component

render() {
    return (
      <div>
          <div v-for={weekDay in this.arWeekDays} >
              <div>{weekDay}</div>
          </div>
      </div>
    )
  }

But this code throws an error "index is not defined".
Tell me, how can I implement the output of elements in a cycle in tsx?
In the example, you need to display the days of the week in a loop. If not done through tsx, then the analogue would look something like this:
<div>
  <div v-for="weekDay in arWeekDays" >
    <div>{{weekDay}}</div>
  </div>
</div>

Answer the question

In order to leave comments, you need to log in

1 answer(s)
0
0xD34F, 2019-09-29
@koliane

v-for={weekDay in this.arWeekDays}

Or maybe "weekDay is not defined" after all? Or are you silent about something?
Forget about v-for:
<div>
  {this.arWeekDays.map(n => <div>{n}</div>)}
</div>

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question