element switch開關文字顯示
element中switch開關把on-text 和 off-text 屬性改為 active-text 和 inactive-text 屬性.怎么把文字描述顯示在開關上?下面就是實現方法:
1 <el-table-column label="狀態"> 2 <template slot-scope="scope"> 3 <el-switch 4 v-model="scope.row.flag" 5 class="demo" 6 active-color="#00A854" 7 active-text="正常" 8 active-value="00000000" 9 inactive-color="#F04134" 10 inactive-text="默認" 11 inactive-value="10000000"/> 12 </template> 13 </el-table-column>
switch開關應用在表格中,效果圖:
下面設置樣式,改變開關文字描述位置(位置大小根據需要可以自行調整):
1 <style> 2 .demo .el-switch__label { 3 position: absolute; 4 display: none; 5 color: #fff; 6 } 7 /*打開時文字位置設置*/ 8 .demo .el-switch__label--right { 9 z-index: 1; 10 right: -3px; 11 } 12 /*關閉時文字位置設置*/ 13 .demo .el-switch__label--left { 14 z-index: 1; 15 left: 19px; 16 } 17 /*顯示文字*/ 18 .demo .el-switch__label.is-active { 19 display: block; 20 } 21 .demo.el-switch .el-switch__core, 22 .el-switch .el-switch__label { 23 width: 50px !important; 24 }
好了,這樣就設置完成,效果如圖所示: