Vue3.js 中按月循环表动态表头

问题描述 投票:0回答:1

我想按月显示表格日期。如何循环表数据?请让我看看。 enter image description here

我尝试过:

tableData: [
        {
          totalSale: 1,
          totalBorrow: 0,
          total: 1,
          details: [
            {
              date: moment("2024-08-01").format("DD/MM/YYYY"),
              totalSale: 1,
              totalBorrow: 0,
              total: 1,
            },
          ],
        },
        {
          totalSale: 2,
          totalBorrow: 1,
          total: 3,
          details: [
            {
              date: moment("2024-09-01").format("DD/MM/YYYY"),
              totalSale: 1,
              totalBorrow: 0,
              total: 1,
            },
          ],
        },
      ],

我的结果:

enter image description here

javascript html vue.js
1个回答
0
投票

我认为您将需要一些额外的逻辑来根据 1-30 和 1-31 制作表格,因为没有足够的代码来帮助您,您可以循环获取如下表格:-

<div v-for="data in tableData">
   <tr>
     <td>{{data.details[0].dat}}</td>
     <td>{{data.totalSale}}</td>

   </tr>
</div>

等等

© www.soinside.com 2019 - 2024. All rights reserved.