Vue3 table.value is undefined

Vue3 table.value is undefined

jemzjemz Posts: 131Questions: 40Answers: 1
edited April 2023 in Free community support

Hi I'm using Vue3

I always get table.value is undefined, what did I miss ?

import DataTable from 'datatables.net-vue3';
import DataTablesCore from 'datatables.net-bs4';
import {onMounted, reactive, ref} from "vue";

DataTable.use(DataTablesCore);

const table = ref();
onMounted(function () {
    let dt = table.value.dt();

    $(dt.table().body()).on('click', 'i', function () {
        alert('test');
    });
});

Thank you in advance.

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 61,972Questions: 1Answers: 10,160 Site admin
    Answer ✓

    Did you include ref="table" on the DataTable component tag?

    Allan

  • jemzjemz Posts: 131Questions: 40Answers: 1
    edited April 2023

    I fixed now thanks missing ref to table also not

    let dt = table.value.dt();
    
    

    but

     dt = table.value.dt;
    
    

    see here https://stackblitz.com/edit/datatables-net-vue3-reactive?file=src%2FApp.vue

  • jemzjemz Posts: 131Questions: 40Answers: 1

    Hi @allan

    Fixed now thanks :)

  • allanallan Posts: 61,972Questions: 1Answers: 10,160 Site admin

    Yes, the API changed. I thought I've fixed the docs for that, but apparently not. Sorry! They are fixed in git now and will be deployed soon.

    Allan

Sign In or Register to comment.