Welcome to OStack Knowledge Sharing 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 Answer

0 votes
by (71.8m points)

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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

2.1m questions

2.1m answers

60 comments

57.0k users

...