template에서 데이터 출력 순서 거꾸로

keep_going·2023년 5월 12일
0

문제해결

목록 보기
27/36
  • 목표)
    template에서 데이터 출력 순서 거꾸로하고 싶음
    왜 script영역에서 안건들였냐? 차트 그래프에는 원래 데이터 순서대로 띄워야 했기문에 변수를 분리해서 담아준 다음에 변환시켜야 했으므로 script에서 건들이는것 보다 template에서 바로 출력 하는게 편하지 않을까 생각했음
<ul v-for="(tmp, i) in this.row.reverse()" :key="i" class="info_body">
  <li class="info_box" v-if="tmp.sellSize">{{ tmp.sellSize }}</li>
  <li class="info_box" v-else>{{ tmp.buySize }}</li>
  <li class="info_box">{{ tmp.price }}</li>
  <li class="info_box">{{ tmp.contractDate }}</li>
</ul>
  • 문제)
    Maximum recursive updates exceeded. This means you have a reactive effect that is mutating its own dependencies and thus recursively triggering itself. Possible sources include component template, render function, updated hook or watcher source function

반응형 데이터가 변경되는데 그걸 계속 참조해서 업데이트를 계속 하고 있다는뜻...

  • 해결)
    slice() 메소드를 사용하여 원본 데이터를 변경하지 않고 배열의 복사본을 만들어서 reverse() 메소드를 적용시킴
<ul v-for="(tmp, i) in this.row.slice().reverse()" :key="i" class="info_body">
profile
keep going

0개의 댓글