vue+element常用小功能(持續(xù)更新中)

1、表格超出顯示省略號

:show-overflow-tooltip='true'

//過長樣式修改
.el-tooltip__popper{
    max-width:20%;
  }
  .el-tooltip__popper,.el-tooltip__popper.is-dark{
    background:rgb(48, 65, 86) !important;
    color: #fff !important;
    line-height: 24px;
  }

2、表單添加紅色星號,但是不會校驗

:required="true"

3、下拉框有值卻無法選中的問題

@change="change()"

change(){
      this.$forceUpdate()
  },

4、選擇框禁止選中

:selectable="checkSelectable"

checkSelectable(row) {
  return row.date == '2016-05-03'
}
//若返回為 true, 則可以選中,否則禁止選中

5、el-input輸入框字符限制,只顯示英文及數(shù)字

<el-input v-model="accountVal" maxlength="24" @input="accountInput" placeholder="請輸入用戶賬號"></el-input>
//通過監(jiān)控輸入框的事實輸入,來進行正則盼盼重新賦值處理

accountInput(val){//賬號的實時輸入
    let codeReg = new RegExp("[A-Za-z0-9]+") //正則 英文+數(shù)字;
    let len= val.length
    let str= ''
    for(var i=0;i<len;i++){
     if(codeReg.test(val[i])){
      str+=val[i];
     }
    }
    this.accountVal=str;
   },

6.element-ui checkbox 設(shè)置選中為1,未選中為0

<el-checkbox v-model="data" :true-label="1" :false-label="0"></el-checkbox>

7.vue組件中props類型及默認(rèn)值

props: {
    String: {
      type: String,
      default: ''
    },
    Number: {
      type: Number,
      default: 0
    },
    Boolean: {
      type: Boolean,
      default: true
    },
    Array: {
      type: Array,
      default: () => []
    },
    Object: {
      type: Object,
      default: () => ({})
    },
    Function: {
      type: Function,
      default: function () { }
    }
  }
最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容