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

修改bug

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