BluePrintJS React InputGroup 组件对于现代用户界面来说非常方便。但不幸的是,React 组件不允许访问内部的 <input> 元素。
我需要访问输入元素有两个主要原因:
如果我的表单中有 50 个 InputGroup,我不想编写 50 个 OnChange() 回调。当用户完成所有输入时,我想获取所有 InputGroup.value(),这是不可能的(由于 HTMLInputElement.value,常规输入元素是可能的,但 InputGroup 不允许访问内部输入)
在表单显示时,我需要关注第一个字段。 InputGroup 没有函数 focus(),而 HTMLInputElement 有一个。
简而言之,InputGroup 中缺少 2 个函数:GetValue() 和 Focus(),我不明白为什么缺少它们。 任何建议将不胜感激。 非常感谢。
最佳答案
我找到了获取输入的方法!与:
inputRef={(input:HTMLInputElement) => {
this.logininput=input;
}}
(第一次没看到)
现在我有了输入对象,我可以将焦点设置在“didmount”,并且我可以使用 logininput.value 获取值。
谢谢
关于css - 我需要访问 InputGroup BlueprintJs react 组件中的输入,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46543795/