General setup for using datatables with Vue 3 and Vue CLI.
General setup for using datatables with Vue 3 and Vue CLI.
creativeone
Posts: 2Questions: 1Answers: 0
Link to test case:
Debugger code (debug.datatables.net):
Error messages shown: $(...).DataTable is not a function
Description of problem: I keep getting Datatable is not a function
Answers
That suggests you haven't included the DataTables library files - try the Download page as that's an easy way to get the libraries.
If that doesn't help, we're happy to take a look, but as per the forum rules, please link to a test case - a test case that replicates the issue will ensure you'll get a quick and accurate response. Information on how to create a test case (if you aren't able to link to the page you are working on) is available here.
Cheers,
Colin
This is a link to a test case in codepen: https://codepen.io/reefboy/pen/JjpPomj
So I imported jquery and datatables in the script tag.
When importing as a CommonJS module, you need to call the function that is imported (docs). So in this case you want:
Then
$().DataTable()
will be available.Note that you will also want to change your life cycle hook to be
mounted
rather thansetup
, since the table isn't in the DOM at the pointsetup
is called.Allan