1. 程式人生 > 其它 >v-for怎麼便利二位陣列

v-for怎麼便利二位陣列

LPL必勝,LPL必勝,LPL必勝,LPL必勝,LPL必勝,LPL必勝,LPL必勝,LPL必勝, LPL必勝,LPL必勝,LPL必勝,LPL必勝,LPL必勝,LPL必勝,LPL必勝,LPL必勝, LPL必勝,LPL必勝,LPL必勝,LPL必勝,LPL必勝,LPL必勝,LPL必勝,LPL必勝, LPL必勝,LPL必勝,LPL必勝,LPL必勝,LPL必勝,LPL必勝,LPL必勝,LPL必勝, LPL必勝,LPL必勝,LPL必勝,LPL必勝,LPL必勝,LPL必勝,LPL必勝,LPL必勝, LPL必勝,LPL必勝,LPL必勝,LPL必勝,LPL必勝,LPL必勝,LPL必勝,LPL必勝, LPL必勝,LPL必勝,LPL必勝,LPL必勝,LPL必勝,LPL必勝,LPL必勝,LPL必勝, <template>   J是第一遍便利的陣列 <div v-for="(j, index) in arr" :key="index" style="width: 98%; margin-left: 1%"> <div style="height: 50px" @click="DIANJI(index)">{{ j.data }}</div> <div> <n-table :bordered="true" :single-line="false" style="margin-bottom: 1%"> <thead> <tr style="margin-top: 50px"> <th>序號</th> <th width="50%">停車場</th> <th>今日交易額</th> <th>今日交易筆數</th> </tr> </thead> <tbody>     這裡面就需要用J.陣列去便利下一個陣列,拿到裡面的內容 <tr v-show="activeIndex===index" v-for="(i, index) in j.state" :key="index"> <td>{{ i.Identifier }}</td> <td>{{ i.paring }}</td> <td>{{ i.Monkey }}</td> <td :class="a">{{ i.Number }}</td> </tr> <tr> <td></td> <td>總計</td> <td>{{ j.sumMonkey }}</td> <td>{{ j.sumNumber }}</td> </tr> </tbody> </n-table> </div> </div> </template> <script> import { defineComponent, onMounted, ref, onBeforeMount } from 'vue'; export default defineComponent({ setup() { const a = ref(null); const arr = ref([ { state: [ { Identifier: '1', paring: '461醫院', Monkey: '101', Number: '290' }, { Identifier: '2', paring: '安華停車場', Monkey: '101', Number: '100' }, ], sumMonkey: 101, data: '2021-12-1', }, { state: [ { Identifier: '3', paring: '巴黎春天停車場', Monkey: '101', Number: '500' }, { Identifier: '4', paring: '北方停車場', Monkey: '101', Number: '1000' }, ], sumMonkey: 10213121, sumNumber: 900, data: '2021-12-2', }, ]); const list = ref([]); console.log(list); const YangShi = ref(true); onMounted(() => { for (let i = 0; i < arr.value.length; i++) { list.value.push(arr.value[i].state); console.log(arr.value[i].state); console.log(list.value); } }); onBeforeMount(async()=>{ console.log("*******onMounted******") }) return { YangShi, a, arr, list, DIANJI(index) { YangShi.value = !YangShi.value; arr.value[index]; }, }; }, }); </script>



<style scoped> .body { background: red; } .cass { background: royalblue; } thead th { text-align: center; } tbody tr { text-align: center; } tbody td { text-align: center; } .nan { height: 100%; } .uau { height: 1px; } </style>