elementUI switch開關文字顯示

// 表格

<el-table-column label="狀態">
  <template slot-scope="scope">
    <el-switch
      v-model="scope.row.flag"
      class="demo"
      active-color="#00A854"
      active-text="正常"
      active-value="00000000"
      inactive-color="#F04134"
      inactive-text="默認"
      inactive-value="10000000"/>
  </template>
</el-table-column>

默認

使用定位來實現

// 樣式
.demo .el-switch__label {
  position: absolute;
  display: none;
  color: #fff;
}
/*打開時文字位置設置*/
.demo .el-switch__label--right {
  z-index: 1;
  right: -3px;
}
/*關閉時文字位置設置*/
.demo .el-switch__label--left {
  z-index: 1;
  left: 19px;
}
/*顯示文字*/
.demo .el-switch__label.is-active {
  display: block;
}
.demo.el-switch .el-switch__core,
.el-switch .el-switch__label {
  width: 50px !important;

結果

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章