Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/asp.net-mvc-3/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Twitter bootstrap 引导数据表和vue_Twitter Bootstrap_Vue.js - Fatal编程技术网

Twitter bootstrap 引导数据表和vue

Twitter bootstrap 引导数据表和vue,twitter-bootstrap,vue.js,Twitter Bootstrap,Vue.js,我正在使用引导数据表和vue.js以及 当我尝试在vue模型创建之后调用DataTable函数时,它不起作用,为什么? 我也尝试了$(app.el).datatable(),但没有成功。 这是我的密码 <table id="example" class="table table-striped table-bordered dt-responsive nowrap" cellspacing="0" width="100%"> <thead> <tr>

我正在使用引导数据表和vue.js以及 当我尝试在vue模型创建之后调用DataTable函数时,它不起作用,为什么? 我也尝试了$(app.el).datatable(),但没有成功。 这是我的密码

<table id="example" class="table table-striped table-bordered dt-responsive nowrap" cellspacing="0" width="100%">
  <thead>
    <tr>
      <th class="all">First name</th>
      <th class="desktop">Last name</th>
    </tr>
  </thead>
  <tbody>
    <tr v-for="ws in workschedule">
      <td>test</td>
      <td>test</td>
    </tr>
  </tbody>
</table>
$(document)
    .ready(function () {
            var app = new Vue({
                el: '#example',
                data: {
                    workschedule: []
        },
                created: function () {
                this.getSchedule();
            },
            methods: {
                getSchedule: function() {
                    var autourl =
                        'get.aspx?op=json&table=StoreUserWorkSchedule&qd=storeuserworkschedule' + appendTime();
                    this.$http.get(autourl)
                        .then(function(response) {
                            this.workschedule = response.data;
                        });
                }
            }
            });
            $('#example').DataTable({
            responsive: true
        });

    });

名字
姓
测试
测试
$(文件)
.ready(函数(){
var app=新的Vue({
el:“#示例”,
数据:{
工作时间表:[]
},
已创建:函数(){
这个.getSchedule();
},
方法:{
getSchedule:function(){
var自动URL=
'get.aspx?op=json&table=StoreUserWorkSchedule&qd=StoreUserWorkSchedule'+appendTime();
此。$http.get(自动URL)
.然后(功能(响应){
this.workschedule=response.data;
});
}
}
});
$('#示例')。数据表({
回答:对
});
});

您正试图访问所创建的钩子中的
$el
属性<代码>$el在安装vue实例后可用,即在挂钩中

因此,在挂载的钩子中调用datatable函数

mounted: function() {    
   this.$el.DataTable({
        responsive: true
    });
}

最后,手表选项解决了这个问题

            var app = new Vue({
                el: '#example',
                data: {
                    workschedule: []
                },
                created: function () {
                    this.getSchedule();
                },
                watch: {
                    workschedule: function (newData) {
                        $('#example').DataTable({
                            responsive: true
                        });
                    }
            },
            methods: {
                getSchedule: function() {
                    var autourl =
                        'get.aspx?op=json&table=StoreUserWorkSchedule&qd=storeuserworkschedule' + appendTime();
                    this.$http.get(autourl)
                        .then(function(response) {
                            this.workschedule = response.data;
                        });
                }
            }
            });

很抱歉,我的问题中有一个问题,我编辑了它,在vue模型创建结束时调用了datatable函数,顺便说一句,我尝试在mount hook中对其进行inovke,但没有成功