1. 程式人生 > 實用技巧 >elementUI表格單選

elementUI表格單選

html程式碼

 1 <el-table :data="tableData">
 2     <el-table-column width="55" label="選擇">
 3        <template slot-scope="props">
 4           <input type="radio" :value="props.row.id" v-model="selectRow" @change="change(props.row)" />  
 5        </template>
 6     </el-table-column
> 7 <el-table-column prop="name" label="課程名稱" width="400"></el-table-column> 8 <el-table-column prop="categoryName" label="課程名稱分類"></el-table-column> 9 <el-table-column prop="lecturerName" label="講師名稱" ></el-table-column> 10 <el-table-column prop
="recommendUnit" label="推薦單位"></el-table-column> 11 <el-table-column prop="id" label="課程id"></el-table-column> 12 <el-table-column prop="paperInfo" label="課後檢測" width="80"></el-table-column> 13 </el-table>

js程式碼

 1  change(item) {
 2      this.selectObj = item;
3 }, 4 sureClick() { 5 bus.$emit(events.selectTask, { 6 name: this.selectObj.name, 7 id: this.selectObj.id 8 }); 9 this.modalVisible = false; 10 }