setNowMaterialType方法被无限调用,实际数组有138个元素,139开始重复打印,v-for完成后应该终止了啊?
<template>
<div class="cpepTemplate">
<table class="tg">
<thead>
<tr>
<th class="tg-baqh" colspan="4">任务项目</th>
<th class="tg-baqh" colspan="3">材料</th>
<th class="tg-baqh" colspan="7">实施方法</th>
<th class="tg-baqh" colspan="3">领域</th>
<th class="tg-baqh" colspan="7">评分</th>
</tr>
</thead>
<template v-for="ele in submitData">
<tr v-if="!setNowMaterialType(ele)">
<td class="tg-yw4l leftAlign bondText" colspan="24">{{ele.MaterialType}}</td>
</tr>
<tr>
<td class="tg-yw4l" colspan="4">{{ele.Name}}</td>
<td class="tg-yw4l" colspan="3">{{ ele.Material}}</td>
<td class="tg-yw4l" colspan="7">{{ ele.Description}}</td>
<td class="tg-yw4l" colspan="3">{{ ele.Domain}}</td>
<td class="tg-yw4l" colspan="7">
<p v-for="item in ele.Options" class="optionBox">
<input type="radio" :value="item.Option"
:id="item.ID" class="radioclass"
@change="selectOption(item.QuestionID,item.Option)"
>
<label :for="item.ID" class="simbleBox"></label>
<label :for="item.ID" class="clickLabel">
<span>{{item.Option}}: {{item.Description}}</span>
</label>
</p>
</td>
</tr>
</template>
</table>
<el-button style="position: fixed;top: 675px;left: 1170px" @click.native="submitResultContent">提交测试</el-button>
</div>
</template>
setNowMaterialType(param) {
// if(this.numberIndex >139 && this.numberIndex<=200 ){
// console.log(param)
// }
// this.numberIndex++;
console.log('JJJJJJJJJJJJJJ')
if (param.MaterialType === this.frstMaterialType) {
return true
} else {
this.frstMaterialType = param.MaterialType;
return false;
}
},
如果只是一个
v-if
,从你的setNowMaterialType
函数来看,并看不到循环console的情况,你可以看下submitData
的值是不是有限的