How to implement Datatables + Vue.js properly

1

my problem is that when integrating datatables.net to my VUE component, I get the following: (image below), but at the time of using the search remains blank

my code in the "< template >" part

and my javascript is the following:

    
asked by yamile ibarra 03.10.2018 в 19:29
source

2 answers

0

After much I found a possible answer,

just add Update

 updated: function () {
   this.$nextTick(function () {
     $('#usuarios1').DataTable({
           'destroy'      :true,
           'stateSave'   : true,

        }).draw();

   })
 }

this goes before the methods, and axios queries have to be in "let"

let data1 =axios.get("api/user").then((response)=>{ this.roles = response.data.roles});

so you can send the information to DataTables

    
answered by 08.10.2018 / 19:24
source
0

Try that instead of filling the table in template , do it for JS.

var data = [
    [
        "Yamile Ibarra xxxxxx",
        "[email protected]",
        "xxxxxxxxxxxxxxxxxxxx",
        "xxxxxxxxxxxxxxxxxxxx",
        "xxxxxxxxxxxxxxxxxxxx",
    ],
    [
        "Jorge xxxxxxx",
        "[email protected]",
        "xxxxxxxxxxxxxxxxxxxx",
        "xxxxxxxxxxxxxxxxxxxx",
        "xxxxxxxxxxxxxxxxxxxx",
    ],
    ...
];

$('#usuarios1').DataTable( {
    data: data,
    ...
} );

Source: link

Greetings!

    
answered by 03.10.2018 в 20:36