在 auto table jspdf 列 VueJs 中创建序号

Creating sequential numbers in the auto table jspdf column VusJs

    columns: [
      {
        header: 'No',
        dataKey: 'Index',
      },
      { header: 'No Registrasi', dataKey: 'no_register' },
      { header: 'Kode Partai', dataKey: 'kode_partai' },
      { header: 'Sumber', dataKey: 'kode_partai' },
      { header: 'Tanggal Panen', dataKey: 'tanggal_panen' },
      { header: 'Tanggal Terima', dataKey: 'tanggal_penerima' },
    
    ],
{
    "success": true,
    "message": "Data ditemukan",
    "data": [
        {
            "id": 15,
            "user_id": 3,
            "no_register": "KREO",
            "kode_partai": "00PPPP",
            "legal_source": "Terdaftar",
            "jenis_sbw_kotor": "9000",
            "tanggal_panen": "2022-02-10",
            "tanggal_penerima": "2022-02-16",
            "alamat": "jl kandir",
            "no_kendaraan": "K 8992993 KW",
            "jumlah_sbw_kotor": "9000",
            "jumlah_pcs": "9000",
            "jumlah_box": "90999",
            "kadar_air": "9000",
            "warna": "Cream",
            "kondisi": "ok",
            "status": "Adding",
            "harga_kulak": "900000000",
            "created_at": "2022-02-24T05:48:07.000000Z",
            "updated_at": "2022-02-24T05:48:07.000000Z"
        },
        {
            "id": 16,
            "user_id": 3,
            "no_register": "KREO",
            "kode_partai": "00PPPP",
            "legal_source": "Terdaftar",
            "jenis_sbw_kotor": "9000",
            "tanggal_panen": "2022-02-10",
            "tanggal_penerima": "2022-02-16",
            "alamat": "jl kandir",
            "no_kendaraan": "K 8992993 KW",
            "jumlah_sbw_kotor": "9000",
            "jumlah_pcs": "9000",
            "jumlah_box": "90999",
            "kadar_air": "9000",
            "warna": "Cream",
            "kondisi": "ok",
            "status": "Adding",
            "harga_kulak": "900000000",
            "created_at": "2022-02-24T05:48:07.000000Z",
            "updated_at": "2022-02-24T05:48:07.000000Z"
        }
    ]
}

我试过使用 index + 1,但它不起作用。我希望根据从 api 服务的响应中获得的数组数量,用序列号填充我的 dataKey。还有什么其他方法可以让我在 'NO' column.I 中输入序列号 使用 Vuejs

您可以使用映射函数向您的数据添加索引字段。


const dataWithIndex = serverResponse.data.map((d,i) => ({...d,Index:i+1}));