try {
try {
this.list.forEach(item => {
.....
throw new Error('end')
})
} catch(err) {
console.log('err',err)
}
// 實例
confirm() {
try {
this.questions.surveyModuleContentDTOS.forEach((item, index) => {
if (item.moduleType === '02') {
console.log('子組件', this.$refs['module' + index][0].checkSelf())
const result = this.$refs['module' + index][0].checkSelf()
if (!result.flag) {
alertDialog({
title: '溫馨提示',
message: `請完成 ${result.questionItem.surveyQuestionDetailDTO.subject}`
})
this.score = 0
throw new Error('end') // 終止循環
}
this.score += result.score
}
})
console.log('執行到這里,說明校驗通過了發送請求', this.score)
alertDialog({
title: '提示',
message: `您的測評得分為 ${this.score}分`,
buttonCallback: () => {
console.log('傳給后端的數據', this.questions)
}
})
} catch (err) {
console.log('err', err)
}
}
}
