[英]Uncaught ReferenceError: jQuery is not defined Laravel
guys. 家伙。 I wanna use Datatables on my view, and I have followed some instructor from the documentation.
我想在自己的视图上使用Datatables,并且从文档中跟随了一些讲师。 But, the datatables won't appear and the console just said "datatables.min.js:17 Uncaught ReferenceError: jQuery is not defined".
但是,数据表不会出现,控制台只会说“ datatables.min.js:17 Uncaught ReferenceError:未定义jQuery”。
here are my codes. 这是我的代码。
head: 头:
<link rel="stylesheet" type="text/css" href="{{ asset(' css/datatables.min.css')}}">
<script type="text/javascript" charset="utf8" src="{{ asset('js/datatables.min.js')}}"></script>
<script src="https://ajax.aspnetcdn.com/ajax/jQuery/jquery-3.3.1.min.js"></script>
View: 视图:
<table class="table table-hover" id="table">
<thead>
<tr text-align="center">
<td scope="col" text-align="center">Pesawat</td>
<td scope="col" text-align="center">Pergi</td>
<td scope="col" text-align="center">Tiba</td>
<td scope="col" text-align="center">Waktu</td>
<td scope="col" text-align="center">Durasi</td>
<td scope="col" text-align="center">Harga</td>
</tr>
</thead>
@if($flight)
@foreach ($flight as $listflight)
<tbody style="text-align: justify;">
<tr>
<td><img src={{$listflight['image']}}>{{$listflight['airlines_name']}}<br>Flight ID - ({{$listflight['flight_id']}}) </td>
<td style="font-size: 15px; padding-top: 50px;">{{$listflight['departure_city_name']}} -{{$listflight['departure_airport_name']}}</td>
<td style="font-size: 15px; padding-top: 50px;">{{$listflight['arrival_city_name']}} - {{$listflight['arrival_airport_name']}}</td>
<td style="font-size: 15px; padding-top: 50px;">{{$listflight['departure_flight_date_str']}}</td>
<td style="font-size: 15px; padding-top: 50px;">{{$listflight['duration']}}
<br> {{$listflight['full_via']}}</td>
<td style="font-size: 15px; padding-top: 40px; color: #ea7a08;">IDR. {{$listflight['price_value']}} <a href="#" class="btn btn-outline-secondary mt-3" style=""><i class="icon fa fa-receipt"></i>Order Ticket</a>
</td>
</tr>
</tbody>
@endforeach
</table>
datatables: 数据表:
@push('script')
<script type="text/javascript">
$(document).ready(function() {
$('#table').DataTable();
});
</script>
@endpush
The order in which you put your script tags in the DOM matters. 将脚本标记放入DOM的顺序很重要。 Datatables depends on jQuery, so jQuery has to be loaded first.
数据表取决于jQuery,因此必须先加载jQuery。
<script src="https://ajax.aspnetcdn.com/ajax/jQuery/jquery-3.3.1.min.js"></script>
<script type="text/javascript" charset="utf8" src="{{ asset('js/datatables.min.js')}}"></script>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.