I am trying to play around with jquery datatable in vue js , however when I change 'Show entries' or enter something in 'Search' no records are displayed Any hint of what am I doing wrong ( I'm not very experienced with Vue Js ) will be highly appreciated Below the code (got it from an example, it seems to load the data in the table ok) :
template>
<div class="Example">
<h2>Implement jQuery DataTable in Vue Js</h2>
<table class="display table-bordered nowrap" cellspacing="0" width="100%" 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.id}}</td>
<td>{{item.product_title}}</td>
<td>{{item.product_price}}</td>
<td>{{item.created_at}}</td>
</tr>
</tbody>
</table>
</div>
</template>
<script type="text/javascript" src="https://code.jquery.com/jquery-3.3.1.js"></script>
<script type="text/javascript" src="https://cdn.datatables.net/1.10.20/js/jquery.dataTables.min.js"></script>
<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://www.testjsonapi.com/products/")
.then((response)=>
{
this.products = response.data;
$('#datatable').DataTable();
})
},
data: function() {
return {
products:[]
}
},
}
</script>