在做后臺(tái)管理系統(tǒng)中遇到一個(gè)需求, 點(diǎn)擊一個(gè)按鈕可以變換里面字的內(nèi)容
當(dāng)狀態(tài)為顯示的時(shí)候, 該行第一個(gè)按鈕為隱藏;
當(dāng)狀態(tài)為隱藏的時(shí)候, 該行第一個(gè)按鈕為顯示;
具體代碼如下:
<!-- 數(shù)據(jù)表格 --> <el-table :data="tableData" class="table" stripe border v-loading="loading"> <el-table-column type="index" label="序號(hào)" width="70"></el-table-column> <el-table-column prop="status" label="狀態(tài)"></el-table-column> <el-table-column label="操作"> <template slot-scope="scope"> <el-button size="mini" type="warning" @click="handleIsDisplay(scope.$index, scope.row)"> {{scope.row.status=='顯示'?'隱藏':'顯示'}} </el-button> <el-button size="mini" type="primary" @click="handleEdit(scope.$index, scope.row)">編輯</el-button> <!-- <el-button size="mini" type="danger" @click="handleRemove(scope.$index, scope.row)">刪除</el-button> --> </template> </el-table-column> </el-table>
也可以用第二種方法:
<!-- 數(shù)據(jù)表格 --> <el-table :data="tableData" class="table" stripe border v-loading="loading"> <el-table-column type="index" label="序號(hào)" width="70"></el-table-column> <el-table-column prop="status" label="狀態(tài)"></el-table-column> <el-table-column label="操作"> <template slot-scope="scope"> <el-button v-if="scope.row.status=='顯示'" size="mini" type="warning" @click="handleIsDisplay(scope.$index, scope.row)">隱藏</el-button> <el-button v-if="scope.row.status=='隱藏'" size="mini" type="warning" @click="handleIsDisplay(scope.$index, scope.row)">顯示</el-button> <el-button size="mini" type="primary" @click="handleEdit(scope.$index, scope.row)">編輯</el-button> <!-- <el-button size="mini" type="danger" @click="handleRemove(scope.$index, scope.row)">刪除</el-button> --> </template> </el-table-column> </el-table>
總結(jié)
以上所述是小編給大家介紹的elementUI Vue 單個(gè)按鈕顯示和隱藏的變換功能,希望對(duì)大家有所幫助,如果大家有任何疑問請(qǐng)給我留言,小編會(huì)及時(shí)回復(fù)大家的。在此也非常感謝大家對(duì)腳本之家網(wǎng)站的支持!
聲明:本網(wǎng)頁內(nèi)容旨在傳播知識(shí),若有侵權(quán)等問題請(qǐng)及時(shí)與本網(wǎng)聯(lián)系,我們將在第一時(shí)間刪除處理。TEL:177 7030 7066 E-MAIL:11247931@qq.com