1. 程式人生 > 其它 >element-ui中給表格新增單選框組(el-radio-group)

element-ui中給表格新增單選框組(el-radio-group)

技術標籤:vue

在這裡插入圖片描述
需求如下:預設選擇每一行的雙向通行,然後可以點選其他並且有排斥的效果

主要是使用三元表示式的多次判斷

程式碼如下:

                <el-table-column prop="b" label="管理" width="620" show-overflow-tooltip align="center">
                    <template slot-scope="scope">
                        <
el-radio-group v-model="scope.row.HandleState" @change="agreeChange(scope.row.HandleState)"> <el-radio :label="1">單向向上</el-radio> <el-radio :label="2" style="margin-left: 40px;">
單向向下</el-radio> <el-radio :label="scope.row.HandleState==1?0:(scope.row.HandleState==2?0:scope.row.HandleState)" style="margin-left: 40px;">雙向通行</el-radio> </el-radio-group> </template>
</el-table-column>

精華所在:

<el-radio :label="scope.row.HandleState==1?0:(scope.row.HandleState==2?0:scope.row.HandleState)"  style="margin-left: 40px;">雙向通行</el-radio>