Skip to content

Instantly share code, notes, and snippets.

@upangka
Last active December 31, 2019 03:57
Show Gist options
  • Save upangka/2011522ed32e46941369d8154fb59c4c to your computer and use it in GitHub Desktop.
Save upangka/2011522ed32e46941369d8154fb59c4c to your computer and use it in GitHub Desktop.
web 常用事件

在web页面编辑中常常涉及到触发事件,以便javascript代码进行处理

事件参考

  1. blur 失去焦点
  2. change 内容改变

Example

elementui el-input-number使用 检验输入的数据

 <el-input-number
    v-model.lazy.number="inputValue"
    :precision="2"
    :controls="false"
    size="small"
    :placeholder="$t('membershipIntroduction.Pleasecontent')"
    :class="{errorClass: inputError}"
    @blur="inputCheckValid"
>
</el-input-number>
<div v-if="inputError" class="show-item">
    <span style="color: red">请输入数额</span>
</div>
data () {
    return {
      inputError: false
    }
  },
methods:{
// ... 
 inputCheckValid () {
   console.log('check input info')
   // 检查输入
   this.inputError = !this.inputValue && this.inputValue !== 0
   return !this.inputError
 },
}
.errorClass{
   /deep/ .el-input__inner{
        border-color: red !important;
    }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment