elementUI 表格中运用radio默认选中与取消

:data="logQueryDataaa" border   highlight-current-row  @row-click="clickrow">
    width="55" align="center">
        
    
    label="手机号" prop="userPhone" align="center" width="200">
    label="姓名" prop="userName" align="center" width="200">
    label="身份证号" prop="idCard" align="center" width="" >

slot="footer" class="dialog-footer" style="text-align: center;margin-top:10px;" > type="primary" @click="sendNewDriver(logQueryDataaa)" >提交
data(){
    return{
   
        logQueryDataaa:[],
        radioData:''
    }
},
    
methods: {
    changeUserPhone(value){
        //int类型转换为string
            this.radioData=value.toString();
    },
    clickrow(row, event, column){
        //获取所需id
        this.radioId = row.id;
    },
    //更换司机
    log_query_short_dataClick4(row, column, cellValue){
   
        let param={
   truckId:row.truckId,companyId:row.companySummaryId};
        logQueryDriverImg(param)
            .then(res=>{
                if(res.status==1){
                    this.logQueryDataaa=res.result;
                    for (let i=0; i; i++){
   //是个数组所以取值时应先循环
                        if (this.driverPhone== res.result[i].userPhone){
   //如果有对应的值则默认选中
                            this.changeUserPhone(this.driverPhone)
                            return;//不加return的话会重复判断导致无法选中
                        }else {
   //如果没有则没有选中
                         this.radioData='';
                        }
                    }
                }else{
                   
                }

            })
    },}

你可能感兴趣的:(工作小总结)