【问题标题】:No Data Available Datatables没有可用的数据数据表
【发布时间】:2021-02-17 03:12:51
【问题描述】:

我试图使用 axios 获取数据,然后将结果显示到 vue 中的数据表 (jQuery) 中。它显示没有可用的数据。 脚本

 async mounted(){
     axios.get("https://www.reddit.com/r/technology/new.json")
     .then( (res) => { 
        this.tableData =  res.data.data.children;
        console.log(this.tableData);
        $(document).ready(function(){
          $('.myDataTable').DataTable();
        });
    });

【问题讨论】:

  • console.log(res) 返回什么?
  • @Catmal 嘿,它从上面的链接返回json数据
  • 上面没有链接..

标签: jquery vue.js asynchronous datatable async-await


【解决方案1】:

试试这个

async mounted(){
 axios.get("https://www.reddit.com/r/technology/new.json")
 .then( (res) => { 
    this.tableData =  res.data.data.children;
    console.log(this.tableData);
    $('.myDataTable').DataTable();
});

问题是您在文档已经加载时使用 $(document).ready() 。所以这部分不会被执行。

【讨论】:

  • 即使我不使用 $(document).ready() 也会显示相同的结果
猜你喜欢
  • 2021-04-17
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2018-09-15
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多