想要获得TtimeList的总个数,数据如下:
teacherList: [ { Tname: 'aaaaaa', Ttime: 'aaaaaaaaaaaaa', TtimeList: [ { Ltime: 'aaaaaaaaaaaaaaaaa', Lunit: 'aaaaaaaaaaaaaaaaaaaaaaaaaaaa' } ] }, { Tname: 'bbbbbb', Ttime: 'bbbbbbbbbbbbbbbbbbb', TtimeList: [ { Ltime: 'bbbbbbbbbbbbbbbb', Lunit: 'bbbbbbbbbbbbbbbbbbbbbbbbbb' }, { Ltime: 'bbbbbbbb', Lunit: 'bbbbbbbbbbbbbb' }, ] }, { Tname: 'cccc', Ttime: 'ccccccccccc', TtimeList: [ { Ltime: 'ccccccccccccccccc', Lunit: 'ccccccccccccccccccccccccc' }, { Ltime: 'ccccccccc', Lunit: 'cccccccccccccccccccccccccccccccccc' }, ] } ], courseOutline: 0,
JS如下:
var len2 = 0; for (var L1 = 0; L1 < this.data.teacherList.length; L1++) { var newArr = this.data.teacherList[L1].TtimeList; for (var L2 = 0; L2 < newArr.length; L2++) { // console.log(newArr[L2]); len2++; } } // console.log(len2); this.setData({ courseOutline: len2 })
wxml如下:
<view>{{courseOutline}}次课</view>
网友评论文明上网理性发言 已有0人参与
发表评论: