<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<script type="text/javascript" src="https://cdn.datatables.net/v/dt/dt-1.10.20/datatables.min.js"></script>
<link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/v/dt/dt-1.10.20/datatables.min.css" />
<link rel="stylesheet" href="./assets/bootstrap.min.css">
<link rel="icon" type="image/x-icon" href="favicon.ico">
<meta name="viewport" content="width=device-width, initial-scale=1.0, shrink-to-fit=no">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/animate.css/3.5.2/animate.min.css">
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Montserrat:400,400i,700,700i,600,600i">
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Nunito:200,200i,300,300i,400,400i,600,600i,700,700i,800,800i,900,900i">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/baguettebox.js/1.10.0/baguetteBox.min.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.11.0/umd/popper.min.js"></script>
<script src="./assets/bootstrap.min.js"></script>
<script src="./assets/bs-animation.js"></script>
<script src="./assets/smoothproducts.min.js"></script>
<script src="./assets/theme.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/baguettebox.js/1.10.0/baguetteBox.min.js"></script>
尽管我已经在我的index.html中导入了DataTable(我使用的是angular 8,但我更喜欢在本地导入它,并且我有这个脚本:
我收到此错误:
Uncaught TypeError: $(...).DataTable is not a function
这是我的html:
<table class="table dataTable my-0" id="dataTableUser"></table>
这是我的脚本:
$(document).ready(function () {
$('#dataTableUser').DataTable();
});
我同意@yazantahhan
,当您使用它来操作DOM时,JQuery和Angular通常会在项目后期导致问题。
但是要解决您的问题,您很可能只需要declare var $ : any;
顶部的.ts
。
我用MatTables代替了dataTables。