vue template 嵌套循环 改造成组件 解决IE 不兼容 template

<td>
                                        <template v-for="dtoLog in item.dtoLog">
                                            <template v-for="userLog in dtoLog.userLog">
                                                <p v-for="logs in userLog.logs">
                                                    <template>
                                                        <h3 v-if="logs.registrationMethod == 0 && !logs.omitException">简单签到</h3>
                                                        <h3 v-if="logs.registrationMethod == 1">语音签到</h3>
                                                        <h3 v-if="logs.registrationMethod == 2">拍照签到<a href="javascript:;" @click="loadPic(logs.localPic)">查看照片</a></h3>
                                                            <h3 v-if="logs.registrationMethod == 3">考勤打卡</h3>
                                                        <h3>{{logs.note ? '('+logs.note+')' : ''}}</h3>
                                                    </template>
                                                </p>
                                            </template>
                                        </template>
                                    </td>

上面的代码是一个表格中一个,td 的内容,为了兼容IE9下不兼容的问题,需要将他们改造成组件的形式;
各位这种循环嵌套怎么办?

阅读 8.3k
1 个回答
computed: {
    logs() {
        let arr = []
        this.item.dtoLog.forEach(t => t.userLog.forEach(t => t.logs.forEach(t => arr.push(t))))
        return arr
    }
}
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题