table<el-table :data="timeTable.courses" border style="width: 100%; margin-top: 20px" > <el-table-column prop ="time" **prop接收的信息** label="时间" width="180"> </el-table-column> <el-table-column prop ="course[0]" label="星期一"> </el-table-column> <el-table-column prop ="course[1]" label="星期二"> </el-table-column> <el-table-column prop ="course[2]" label="星期三"> </el-table-column> <el-table-column prop ="course[3]" label="星期四"> </el-table-column> <el-table-column prop ="course[4]" label="星期五"> </el-table-column> <el-table-column prop ="course[5]" label="星期六"> </el-table-column> <el-table-column prop ="course[6]" label="星期日"> </el-table-column></el-table><script>export default {data() {return { timeTable:{ studentName:'格式化灰忆', class:'201705', term:'', courses:new Array(5), **课程数组接收数组** }};},mounted () {const that = this;this.$http.get( that.$interface+'queryClass?term=2016-2017-2') .then(function (response) { if(response.data!==false){ for(var i = 0;i<5;i++){ **数组的格式** that.timeTable.courses[i] = {time:(2*i+1) + ',' + (2*i+2),course:["","","","","","",""]}; } response.data.data.forEach(function(item){ **从后台获取数据遍历** var temp = item.classTime.split('-'); var row = (temp[1]- 1)/2; var col = temp[0] - 1; that.timeTable.courses[row].course[col] = item.course; }); console.log(that.timeTable.courses); }else{ that.$message({ message: response.data.msg, type: 'warning' }); } }) .catch(function (err) { console.log(err); that.$message({ message: '数据 error', type: 'warning' }) });},methods:{}}</script>
添加回答
举报
0/150
提交
取消