首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >在酶中检测input.focus()

在酶中检测input.focus()
EN

Stack Overflow用户
提问于 2016-06-08 06:34:24
回答 8查看 42.7K关注 0票数 24

如何在酶中检测input.focus()。我在用反应来写剧本。我的代码如下:

代码语言:javascript
复制
public inputBox: any;

componentDidUpdate = () => {
    setTimeout(() => {
        this.inputBox.focus();
    }, 200);
}

render() {
    return (
        <div>
            <input
                type = 'number'
                ref = {element => this.inputBox = element } />
        </div>
    );
}
EN

Stack Overflow用户

发布于 2019-08-09 12:21:04

可以使用选择器检查特定元素。

代码语言:javascript
复制
const wrapper = mount(<MyComponent />);

const input = wrapper.find('input');
expect(input.is(':focus')).toBe(true);
票数 2
EN
查看全部 8 条回答
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/37694900

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档