前端element框架之动态渲染后端传递的数据

最进在接触一些前端,在使用vue 的element ui 构建表格的时候,出现一些问题,其中一个问题就是接收到后端的数据,但是不能渲染,或者渲染失败。所以我整理总结一下主要的问题和解决方法。

<el-table :data="tableData" height="400" border style="width: 700">
   <el-table-column align="center" prop="file_name" label="日期" min-width="90/100">
   </el-table-column>
   <el-table-column prop="status" label="状态" min-width="10/100">    
   </el-table-column>
</el-table>

var vm = new Vue({
	el: '#app',
	data() {
		return {
			car_index: '',   
            car_toindex: '',  
            time: '',  
            data_time: { 
                startTime: '',
                endTime: '',
            }, 
            jsons_data: '', 
            tableData: [],  
            options: {{ options|safe }}, 
		}
	},
	methods:{
		    searchvideos(){ // 搜索视频功能
            var _this = this
            
            this.car_toindex = this.car_index 
            this.data_time.startTime = this.time[0]
            this.data_time.endTime = this.time[1]

            this.jsons_data = {
                car_toindex: this.car_toindex,
                start_data: this.data_time.startTime,
                end_data: this.data_time.endTime
            }
			// 这种方法不要用,我也不知道为什么,_this.tableData = res.data,这一步就是不能成功
            // $.ajax({
            //     async: false,
            //     url: '/test/getvideos/',
            //     type: 'post',
            //     dataType: 'json',
            //     data: this.jsons_data,
                
            //     success: function (res) {
						_this.tableData = res.data
            //     }
            // })
            axios.post('/test/getvideos/', this.jsons_data)
                .then(function (res) {
                    console.log(res);
                    _this.tableData = res.data
                })
                .catch(function (error) {
                    console.log(error)
                })
        },
	}
})

在这里插入图片描述

我是清茶!欢迎你和我一起讨论,我们下期见。

  • 5
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值