vue3 datatable styling not working

vue3 datatable styling not working

jemzjemz Posts: 131Questions: 40Answers: 1

Hi need some help please, I am using vue3 and datables, I followed this basic example https://datatables.net/blog/2022-06-22-vue, but unfortunately, the styling did not work. as you can see on my screenshot the table display did not work.

Answers

  • rf1234rf1234 Posts: 2,997Questions: 87Answers: 421

    but unfortunately, the styling did not work. as you can see on my screenshot the table display did not work.

    Too bad, it didn't work. But without a test case or your code I am afraid nobody will be able to help you.

  • jemzjemz Posts: 131Questions: 40Answers: 1

    If I hover the this import DataTableBs5 from 'datatables.net-bs5';

    it says dataTables.bootstrap5.d.ts is not a module

  • jemzjemz Posts: 131Questions: 40Answers: 1
    edited September 2022
    <template>
      <div class="about">
    
        <h1>This is an about page</h1>
    
    
          <DataTable :data="data" class="display" width="100%">
            <thead>
            <tr>
              <th>A</th>
              <th>B</th>
            </tr>
            </thead>
          </DataTable>
    
      </div>
    
    </template>
    
    <script setup lang="ts">
    
    import * as bootstrap from 'bootstrap';
    import DataTable from 'datatables.net-vue3';
    
    import DataTableBs5 from 'datatables.net-bs5';
    DataTable.use(DataTableBs5);
    
    const data = [
      [1, 2],
      [3, 4],
    ];
    
    </script>
    
    <style >
    @import 'bootstrap';
    @import 'datatables.net-bs5';
    </style>
    
  • jemzjemz Posts: 131Questions: 40Answers: 1

    it's working now

  • KyokuSamaKyokuSama Posts: 1Questions: 0Answers: 0

    Hi @jemz .
    Could you explain how you solved this?

  • allanallan Posts: 63,523Questions: 1Answers: 10,473 Site admin

    I would guess by adding the class table to the table or possibly just style="width: 100%" as the rest looks okay.

    If that doesn't fix it for you, please link us to your page so we can take a look into it.

    Allan

Sign In or Register to comment.