Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

320
Views
getting Uncaught (in promise) TypeError: $(...).DataTable is not a function while using datatables in vite vuejs

I am trying to add datatables into my vite vuejs Application but getting an error while using it. Here is my error.

"Uncaught (in promise) TypeError: $(...).DataTable is not a function" 

Here is my packages list.

  • jquery
  • datatables.net-dt
  • bootstrap
  • axios

and here is my code.

<template>
<div>
<h2>Implement jQuery DataTable in Vue Js</h2>
<table class="table" id="datatable">
  <thead>
    <tr>
      <th>ID</th>
      <th>Product Title</th>
      <th>Product Price</th>
      <th>Created On</th>
    </tr>
  </thead>
  <tbody>
    <tr v-for="item in products" :key="item.id">
      <td>{{ item.userId }}</td>
      <td>{{ item.id }}</td>
      <td>{{ item.title }}</td>
      <td>{{ item.completed }}</td>
    </tr>
  </tbody>
</table>
</div>
</template>

<script>
import 'jquery/dist/jquery.min.js';
import 'bootstrap/dist/css/bootstrap.min.css';
import "datatables.net-dt/js/dataTables.dataTables"
import "datatables.net-dt/css/jquery.dataTables.min.css"
import axios from 'axios';
import $ from 'jquery'; 

export default {
 mounted() {
 axios.get("https://jsonplaceholder.typicode.com/todos").then((response) => {
  this.products = response.data;
  $("#datatable").DataTable();
  });
 },
 data: function () {
  return {
   products: [],
 };
 },
 };
 </script>

I already trying to do it with standard HTML from like adding link and script tag to index.html file of vuejs app. working fine but hot reload is not working for the datatable, I always need to refresh the page to see the datatables impact.

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!