原型效果:
代碼實現:
<el-table-column property="address" label="操作"> <template slot-scope="scope"> <el-button @click="setGrade(scope.row)" type="text" size="small" >等級設置</el-button > <el-button @click="evaluationResult(scope.row)" type="text" size="small" >等級評價結果</el-button > <el-button @click="handleClick(scope.row)" type="text" size="small" >修改</el-button > <el-button v-if="scope.row.module == '啟用中'" @click="handleClick(scope.row)" type="text" size="small" >停用</el-button > <el-button v-if="scope.row.module === '已停用'" @click="handleClick(scope.row)" type="text" size="small" >啟用</el-button > <el-button @click="handleClick(scope.row)" type="text" size="small" >刪除</el-button > </template> </el-table-column>
通過 v-if指令 決定按鈕的顯示隱藏。