Advertisement

el-radio遇到的一些坑

阅读量:

radio下面的數據是上一層的table 展開的

問題1:選擇了其中一個,其他expand的數據都會被選中

思路:根據父級table然後選擇了子級radio

复制代码
  <el-table fit style="width: 100%;" :data="goodsData" :row-key="getRowKeys" :expand-row-keys="expands" border @current-change="toggleRowExpansion">

    
       <el-table-column type="expand" :label="$t('commonText.switch')" width="80px">
    
     <template slot-scope="props">
    
       <el-table label-position="left" :data="suppliersData" border fit>
    
         <el-table-column :label="$t('pageInquiryView.choice')" align="center" min-width="80">
    
           <template slot-scope="scope">
    
             <el-radio-group v-model="choice[props.$index].radio" @change="handleChange(props)">
    
               <el-radio :label="scope.$index">
    
                 <!--  {{ props.row. isSelected }} -->
    
               </el-radio>
    
             </el-radio-group>
    
           </template>
    
         </el-table-column>
    
         <el-table-column :label="$t('pageSupplierView.supplierNo')" align="center" min-width="150">
    
           <template slot-scope="scope">
    
             <span>
    
               {{ scope.row.supplierNo }}
    
               <!-- supplierNo -->
    
             </span>
    
           </template>
    
         </el-table-column>
    
         </el-table>
    
         </el-table-column>
    
         </el-table>
    
    
    
    
    代码解释

問題2:如果有多個數據需要在data寫多個radio

決解方式:去掉choice[props.$index].radio中的radio就搞定了

全部评论 (0)

还没有任何评论哟~