Welcome toVigges Developer Community-Open, Learning,Share
Welcome To Ask or Share your Answers For Others

Categories

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

vue render el-table,列使用fixed。点击单元格动态切换input,input获取焦点方法失效 求大佬指导

this.$nextTick(function() {
    console.log(this.$refs.inputRef)
    this.$refs.inputRef.focus();
});

this.$refs.inputRef 是可以获取到值的 但是focus() 方法不生效
去掉fixed 后方法是可以生效的


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

1 Answer

0 votes
by (71.8m points)

不是很了解 element-UI。

遇到这种问题我一般会试着用一个 setTimeout(f, 10000) 这样的定时器替换 $nextTick(),看是不是有一些框架定时器之类的在起作用;或者直接在命令行里找到这个 <input>,然后 input.focus() 看能否获取焦点。排除这两个问题之后,再研究为什么 fixed 会导致目前的问题。

当然你也可以直接看源码。


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to Vigges Developer Community for programmer and developer-Open, Learning and Share

2.1m questions

2.1m answers

63 comments

56.6k users

...