Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
4.1k views
in Technique[技术] by (71.8m points)

el-input 怎么实现动态禁用

使用el-input 想实现动态禁用 当失去焦点时禁用input,点击input时 重新获取焦点取消禁用 我现在的写法禁用后没有办法重新获取焦点取消禁用,想知道怎么实现

<el-input
  v-model="state"
  :disabled="sss"
  placeholder="请输入内容"
  @focus="focusff"
  @blur="blurdd"
/>
data() {
      return {
        state: ''
        sss: true
      };
    },
methods: {
      blurdd() {
        this.sss = true
        console.log('触发1')
      },
      focusff() {
        this.sss = false
        // if(input.blur) {return this.sss = true };
        console.log('触发2')
      },

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

把聚焦事件改为点击事件,然后判断禁用状态,如果是禁用状态就取消禁用并聚焦,如果已经聚焦则不做处理


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

1.4m articles

1.4m replys

5 comments

57.0k users

...