以上面方式传给后端
// 获取安全培训题目
const getDriverSafetyExam = () => {
let params = {
city_id: uni.getStorageSync('city_id'),
type: uni.getStorageSync('need_pre')
}
getDriverSafetyPreWorkExam(params).then((resData) => {
if (resData.code !== 0) {
return uni.showToast({
title: resData.message,
icon: 'none',
duration: 1500
});
}
SafetyExamData.value = resData.data
tiku_type_id.value = resData.data[0].tiku_type_id
city_channel_id.value = resData.data[0].city_channel_id
//赋值对应的题目,以及多少题
for (let index in resData.data) {
safetyNumber.value.push({
exam_id: resData.data[index].id,
select_id: 0
})
}
})
}
<view class="safety_training_content_bg">
<view v-for="(safety, index) in safetyNumber" class="safety_training_content">
<view class="safety_training_title">{{index+1}}.{{SafetyExamData[index].exam_desc}}</view>
<uv-radio-group v-model="safety.select_id">
<uv-radio :customStyle="{margin: '8px'}" v-for="(item, id) in SafetyExamData[index].answers" :key="id"
:label="item.answer_desc" :name="item.id">
</uv-radio>
</uv-radio-group>
</view>
</view>
上面是渲染,以及选项值