某个computed出现的意料之外的循环调用?
computed: {
filteredJobList(data) {
console.log('filteredJobList computed');
var jobColorMap = data.$state.jobColorMap
if (data.filterColor != 'transparent' && jobColorMap) {
return utils.getJobIdsByColor(data.jobList, data.filterColor)
}
return data.jobList
},
filterStatisticsArr(data) {
console.log('filterStatisticsArr computed');
var arr = [{
count: 0,
name: '未完成',
},
{
count: 0,
name: '待办项',
},
{
count: 0,
name: '已完成',
},
{
count: 0,
name: '已超时',
}
]
var now = new Date().getTime()
var jobList = data.filteredJobList
if (jobList && jobList.length) {
for (const j in jobList) {
var job = jobList[j]
if (job.jobState == 1) {
// 已完成
arr[2].count++;
} else {
// 未完成
arr[0].count++;
if ((new Date(job.jobEndTime)).getTime() < now) {
// 已超时
arr[3].count++;
}
if (job.reportList
.map(item => item.createTime.substr(0, 10))
.indexOf(dateUtils.format(new Date())) == -1) {
// 今日未跟进
arr[1].count++;
}
}
}
}
return arr
}
},
<navigator url="/pages/team-member-job-list/team-member-job-list?userId={{userId}}" class="statistics-item" wx:for="{{filterStatisticsArr}}" wx:key="name">
<view class="primary-color count">{{item.count}}</view>
<view class="name">{{item.name}}</view>
</navigator>
如上,我本意是想在__filteredJobList__更新的时候改变__filterStatisticsArr__,但是filteredJobList被调用一次后filterStatisticsArr意料之外的会被重复调用到崩溃(301次),如果将filterStatisticsArr中的forin语句删除的话又不会有这样的情况了。。。望大神解答困惑,感谢