小编Sac*_*in 的帖子

在Enzyme中测试input.focus()

任何人都可以帮我测试酶中的input.focus().我正在用react.My代码编写脚本.

public inputBox: any;

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

render() {
    return (
        <div>
            <input
                type = 'number'
                ref = {element => this.inputBox = element } />
        </div>
    );
}
Run Code Online (Sandbox Code Playgroud)

typescript reactjs enzyme

16
推荐指数
3
解决办法
2万
查看次数

标签 统计

enzyme ×1

reactjs ×1

typescript ×1