1. 程式人生 > 實用技巧 >vue+element中,根據狀態的不同,顯示不同的操作按鈕

vue+element中,根據狀態的不同,顯示不同的操作按鈕

原型效果:

程式碼實現:

 <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指令 決定按鈕的顯示隱藏。