If you add if to the vue function, you will report an error, but if you don't add it, it will be normal.

normal code (no if):

//
issue:function(){
    this.result = [];
    for(var i=0;i<this.formData.length;iPP){
        let obj = {
            questionUid:this.formData[i].questionUid, //id
            questionType:this.formData[i].questionType, //1:23
            //
            userBlanksDetail:{
                answer:this.formData[i].fill
            },
            //
            userOptionDetail:{
                optionUid:this.formData[i].single?this.formData[i].single:this.formData[i].mul.join(",")
            }
        }
        this.result.push(obj);
    }
    this.submit(); //
},

if you add if, you will report an error:

//
issue:function(){
    this.result = [];
    for(var i=0;i<this.formData.length;iPP){
        let obj = {
            questionUid:this.formData[i].questionUid, //id
            questionType:this.formData[i].questionType, //1:23
            //if
            if(this.formData[i].questionType == 3){
                userBlanksDetail:{
                    answer:this.formData[i].fill
                },
            }
            //
            userOptionDetail:{
                optionUid:this.formData[i].single?this.formData[i].single:this.formData[i].mul.join(",")
            }
        }
        this.result.push(obj);
    }
    this.submit(); //
},

clipboard.png

what kind of strange phenomenon is this?


if(this.formData[i].questionType == 3){
    userBlanksDetail:{
        answer:this.formData[i].fill
    },
}
Change

to

userBlanksDetail:{
    answer:this.formData[i].questionType == 3?this.formData[i].fill:''
},


for(var i=0;i<this.formData.length;iPP){
        let obj ={};
        if(this.formData[i].questionType == 3){
         obj = {
            questionUid:this.formData[i].questionUid, //id
            questionType:this.formData[i].questionType, //1:23
            //
            userBlanksDetail:{
                answer:this.formData[i].fill
            },
            //
            userOptionDetail:{
                optionUid:this.formData[i].single?this.formData[i].single:this.formData[i].mul.join(',')
            }
        }
        }else{
            obj = {
            questionUid:this.formData[i].questionUid, //id
            questionType:this.formData[i].questionType, //1:23
            //
            userOptionDetail:{
                optionUid:this.formData[i].single?this.formData[i].single:this.formData[i].mul.join(',')
            }
        }
        }
        this.result.push(obj);
    }

what kind of strange phenomenon is this?

what is your strange way of writing? I'm afraid I can't understand

.

this is a creative way of writing. Did you invent it? But javascript engine doesn't recognize it?


what kind of strange phenomenon is this?

with all due respect, this method of writing, not to mention putting it in vue, will not succeed in any js running program of react ng jquery!

if no one writes this, there is a problem with grammar. So:

let obj = {
    1: 'value1',
    2: 'value2',
    : condition ? 'value1' : 'value2',
}

// 
if () {
    obj[''] = ''
}
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b386c4-344c1.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b386c4-344c1.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?