实现效果:
    image.png image.png

    首先这道题是: 发送完ajax之后,后端会给我们一个状态,就是’questionType’ 这个代表questionType为”1”,就是单选,questionType为”2”就是多选,questionType为”3”就是简答, 那么我们实现单选多选的默认选中是还要分情况的,
    对了,后端还返回一个值给我们,就是isRight ,

    1. // 单选多选默认选中的方法
    2. choiceFn () {
    3. // alert(this.list.questionType)
    4. if (this.list.questionType === '2') {
    5. this.list.options.forEach(it => {
    6. if (it.isRight === 1) {
    7. this.checkList.push(it.code)
    8. }
    9. })
    10. } else if (this.list.questionType === '1') {
    11. this.list.options.forEach(it => {
    12. if (it.isRight === 1) {
    13. this.radio = it.code
    14. }
    15. })
    16. }
    17. },