表单失去焦点校验数据后,有问题的焦点激活

 <el-input
                  v-model="scope.row.setMaxScore"
                  :ref="`inputRefs${scope.$index}`"
                  size="small"
                  @blur="changeMax
                (scope.$index,scope.row)"

                ></el-input>
    //鼠标离开
    changeMax(index, row) {
      this.rowIndex = index;
     this.maxScore = row.setMaxScore;
      this.minScore = row.setMinScore;
      if(this.minScore!=''&&this.maxScore==''){
        return
      }
      else{
        if(Number(this.minScore) >=Number(this.maxScore)){
      this.$message.error('第'+(this.rowIndex+1)+'行最大值应该大于最小值')
      this.$refs[`inputRefs${index}`].focus()

//有的时候要加
[0]
this.$refs[`stepInputRefs${mindex}a${index}`][0].focus();
      }
      }

    },

 

export default {
  name: "SetGrade",
  components: {},
  
  directives: {
    focus: {
        // 指令的定义
        inserted: function(el){
            el.focus()
        }
    }
  },
}

 

posted @ 2020-09-01 15:45  ThisCall  阅读(280)  评论(0编辑  收藏  举报