答案 0 :(得分:8)
如果要将jQuery作为本地库导入,请在* component.ts文件中,例如:
import * as jquery from 'jquery'
删除该行并将其视为全局库:
declare var jquery: any;
或
declare var $: any;
或者只是将这两行中的一行添加到src / typings.d.ts
答案 1 :(得分:1)
添加后仍然无法获取datable(datatable不是函数)
import * as $ from 'jquery';
然后我添加了以下代码,它现在也可以正常工作:
import 'datatables.net';
如果仍然收到错误,请尝试以下操作:
import 'datatables.net-bs4';
答案 2 :(得分:-1)
拉拉维(Laravel)提出“渲染”,并取消了导入。
Mi app.blade.php
<script src=" {{ asset('/assets/admin/plugins/jquery/jquery.min.js') }} "></script>
<script src=" {{ asset('/assets/admin/plugins/bootstrap/js/bootstrap.bundle.min.js') }} "></script>
<script src=" {{ asset('/assets/admin/dist/js/adminlte.min.js') }} "></script>
@yield('scripts')
您可以从文件中获取延期的信息吗?
@section('scripts')
<!-- DataTables -->
<script src=" {{ asset('/assets/admin/plugins/datatables/jquery.dataTables.min.js' ) }} " defer></script>
<script src=" {{ asset('/assets/admin/plugins/datatables-bs4/js/dataTables.bootstrap4.min.js') }} " defer></script>
<script src=" {{ asset('/assets/admin/plugins/datatables-responsive/js/dataTables.responsive.min.js') }} " defer></script>
<script src=" {{ asset('/assets/admin/plugins/datatables-responsive/js/responsive.bootstrap4.min.js') }} " defer></script>
<script src=" {{ asset('/assets/admin/usuarios/listar_usuarios.js') }} "></script>
@endsection