日本免费高清视频-国产福利视频导航-黄色在线播放国产-天天操天天操天天操天天操|www.shdianci.com

學無先后,達者為師

網站首頁 編程語言 正文

element組件autofocus( 自動獲取焦點)失效

作者:大大。 更新時間: 2023-10-16 編程語言

?如果加了autofocus還是無效,那么可以用以下方法

 <el-input
    v-model="patientId"
    placeholder=""
autofocus
    ref="input1"
></el-input>

注意如果使用ref使用動態id,那么 :ref="id"
 // 在需要獲取焦點的地方
  var that = this;
      this.$nextTick(() => {
        that.$refs['input1'].focus();
      });


如果refs使用動態的id,那么修改為that.$refs[id].focus();

下面是我使用時代碼?

<div >
        <el-input v-if="scope.row.ModelSquare==true" @blur="ModelSquareClose(scope.$index,scope.row.id,scope.row.square)" v-model="scope.row.square" class="inp_dz" autofocus=true :ref="scope.row.id" size=small>
                    <span slot="suffix" class="span_suf">㎡</span>
                  </el-input>
                  <i v-else class="el-icon-edit-outline blue_color" @click="ModelSquareEdit(scope.$index,scope.row.id)"></i>
                </div>
 ModelSquareEdit(index, id) {
      //input出現
      console.log(id, 'id');
      if (this.AuditList.length > 0) {
        this.AuditList[index].ModelSquare = true;
      }
      // this.AuditQuoteList[index1].list[index2].ModelCheck2 = true;

      this.$forceUpdate();

      if (this.timer2) {
        clearTimeout(this.timer2);
      }
      var that = this;
      this.$nextTick(() => {
        that.$refs[id].focus();
      });
    },
    ModelSquareClose(index, id, square) {
      //input消失關閉  
      if (this.AuditList.length > 0) {
        this.AuditList[index].ModelSquare = false;
      }
      if (square) {
        this.updateSquareClick(id, square);
      } else {
        this.get_audit_detail();
      }

      this.$forceUpdate();
    },

原文鏈接:https://blog.csdn.net/weixin_43923808/article/details/131222634

  • 上一篇:沒有了
  • 下一篇:沒有了
欄目分類
最近更新