提交 56887b98 authored 作者: lihuihui's avatar lihuihui

修改bug

上级 b75b6172
<template>
<div class="radio-box">
<template v-for="(item, index) in option || datas">
<template v-for="(item, index) in option">
<div class="opt" :key="index">
<el-radio v-model="radioValue" :label="index" @change="radioChange">
<el-tag>{{ A_Z()[index] }}</el-tag>
<el-input v-model="item.option" maxlength="80" show-word-limit></el-input>
</el-radio>
<i class="el-icon-remove-outline icon-style" v-if="index != datas.length - 1" @click="remove(index)"></i>
<i class="el-icon-remove-outline icon-style" v-if="index != option.length - 1" @click="remove(index)"></i>
<i class="el-icon-circle-plus-outline icon-style" v-else @click="add"></i>
</div>
</template>
......@@ -23,36 +23,22 @@ export default {
data() {
return {
radioValue: 0,
datas: [
{
checked: true,
option: ''
},
{
checked: false,
option: ''
},
{
checked: false,
option: ''
}
],
ruleForm: ''
}
},
mounted() {
if (this.option) {
this.datas = this.option
this.radioValue = this.datas.findIndex(item => item.checked)
}
this.radioValue = this.option.findIndex(item => item.checked)
},
methods: {
// 添加选项
add() {
this.datas.push({ option: '', checked: false })
this.option.push({ option: '', checked: false, id: 0 })
},
// 删除选项
remove(index) {
this.datas.splice(index, 1)
this.option.splice(index, 1)
},
// ABCD
A_Z() {
const result = []
for (let i = 0; i < 26; i++) {
......@@ -60,10 +46,11 @@ export default {
}
return result
},
// 选择正确答案
radioChange() {
this.datas.map(item => {
this.option.map(item => {
item.checked = false
this.datas[this.radioValue].checked = true
this.option[this.radioValue].checked = true
return item
})
}
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论