- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在尝试弄清楚如何将参数/ Prop 传递给来自 React Native Paper 的输入,因为 React Native Paper 没有合适的下拉菜单,所以有一个我喜欢的“菜单”在我的项目上实现,但文档太糟糕了,没有关于如何从该项目获取元素的示例,也没有将该参数传递给其他地方。
<TextInput
style={{width: 300, backgroundColor: 'transparent', margin: 0, padding: 0}}
label='Email'
value={Username}
onChangeText={User => setUsername(User)}
/>
如你所见,这是菜单
<Provider>
<Menu
visible={isOpen}
onDismiss={() => setOpen(false)}
anchor={
<Button style={{marginTop: 25}} color="#8DB600" icon="account" dark={true} mode="contained" onPress={() => setOpen(true)}>
Ingresar
</Button>
}>
<Menu.Item onPress={() => {}} title="Item 1" />
<Menu.Item onPress={() => {}} title="Item 2" />
<Menu.Item onPress={() => {}} title="Item 3" />
</Menu>
</Provider>
我的想法是按下 anchor 上的那个按钮,显示菜单并选择一个项目,然后那个项目显示在文本输入上,就像我在这个组件中输入一样
最佳答案
假设文本输入和下拉菜单都是同一个组件的一部分 - 使用 setUsername 更改 Username
的值将更新文本输入
const [Username, setUsername] = useState(''); // both components must have access to Username state
<TextInput
style={{width: 300, backgroundColor: 'transparent', margin: 0, padding: 0}}
label='Email'
value={Username}
onChangeText={User => setUsername(User)}
/>
<Provider>
<Menu
visible={isOpen}
onDismiss={() => setOpen(false)}
anchor={
<Button style={{marginTop: 25}} color="#8DB600" icon="account" dark={true} mode="contained" onPress={() => setOpen(true)}>
Ingresar
</Button>
}>
<Menu.Item onPress={() => setUsername("Item 1")}} title="Item 1" /> // directly set username like this
<Menu.Item onPress={() => setUsername("Item 2")} title="Item 2" />
<Menu.Item onPress={() => setUsername("Item 3")} title="Item 3" />
</Menu>
</Provider>
为什么这有效 - doc
The value to show for the text input. TextInput is a controlled component, which means the native value will be forced to match this value prop if provided.
编辑:完整的工作示例 - https://snack.expo.io/4I0Xr0HBR
关于javascript - 我如何将所选项目从 React Native Paper Menu 传递到 Input/TextInput onChangeText 行为,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61604500/
我正在开发一个应用程序,其中日期以 yyyy-mm-dd 形式传递,但向客户端显示为 mm-dd-yyyy(美国客户端)。 我正在使用 jQuery 日期选择器在报告中选择起止日期,并希望将日期显示为
当传递道具可编辑=FALSE时,反应原生更改文本颜色。。如何更改文本输入颜色?我已经阅读了文档https://reactnative.dev/docs/textinput,但没有得到帮助
我有一个 ScrollView 到 TextInput 控件。 单击 TextInput 时,键盘会按预期出现。如果我在 View 区域中的 TextInput 外部单击,键盘
在关闭键盘或按其他地方后,如何摆脱文本输入中的光标? 这就是我所有的 TextInput: 最佳答案 我知道这个问题有点老了,但只要改进 Martin 的回答你就可以做到: componentDid
所以我会试着解释我的场景。 我有一个单行 TextInput .当用户是 onFocus ,文内TextInput可以长于 TextInput本身。 但是,当用户不再onFocus ,Android
这真的很烦人,当我在一个 TextInput 中写入文本时,我点击另一个 TextInput 以在键盘准备好时获得焦点,但它只会隐藏键盘。如何克服这种行为?我只想点击 TextInput 并立即准备好
我想知道在 python 和 Kivy 中是否可以像在 HTML/CSS 中那样自定义 TextInput 小部件。有什么方法可以直接在我的 CustomTextInput(TextInput) 类中
有没有办法做到这一点,如果用户到达 textInput 字段上“行”的末尾,它会在下一行继续并增加文本框的高度,以便他们可以看到他们输入的全部内容?现在,文本继续在同一行上,使首先输入的内容不再可见。
我已经为 TextInput 创建了公共(public)类并多次使用它,但它的事件句柄使用相同的方法。我想在 textInput 中填充数据后处理数组数据。 这里添加了多个textField和单个ha
我是一个新手,无法做出本地 react ,并正在努力解决以下问题。我正在执行更新功能,一旦选择了用户,该用户的数据就会填充到其专用字段 TextInput 中,例如 given_name、family
使用 React Native TextInput,在键盘可见的情况下点击后退按钮(屏幕截图中的红色 1)时,可以稍后编辑 TextInput 值。但是,当点击检查/输入图标(屏幕截图中的红色 2)时
我想要一个输入文本,一旦达到最大值就自动跳转到另一个输入文本字段。 这是示例文本字段。 Identification card: - - 如何让输入的文本字段在第一个文本字段达到最大数量后立即跳
我遇到了这种非常奇怪的行为.. 这是我的代码的简化版本: DOWN = 40; UP = 38; $(document).on("keydown", "#text_input", function(e
当我点击它时,我有一个名为电子邮件或用户名的文本输入,它不显示我键入的值,我认为这是因为屏幕尺寸,无论如何我可以调整 Textinput 以便当我单击它,全文输入显示,我可以看到我输入的值。它下方的其
我的 app.js 中有一个 TextInput ,但它位于页面中间,但我希望它位于页面顶部,我的意思是就在通知栏下方,请问我该怎么做 const BackStyles
我正在尝试使用kv语言重做我已经完成的程序。第一个是用 python 完成的。现在,当我使用 kivy 语言时,我无法从用户界面中获取任何内容。在这个例子中。当条形码文本更改时,它应该更新它的文本属性
我在使用 TextInput 时遇到问题 预期的行为是,当我点击它时,它会聚焦并显示键盘,当我在它周围点击时(除了输入之外的任何地方),TextInput应该模糊并且键盘会消失。目前这不会发生,无论我
我有一个问题,当我在 TextInput 中输入垃圾邮件并单击按钮提交并清除文本时,它变得迟缓并且不会立即清除 TextInput 中的文本。当我在屏幕中有很多内容(如 Lorem Ipsum 文本)
我正在使用函数更新 onChangeText 事件上的 TextInput 值。如果我在函数中状态更新后控制台记录该值,它会打印更新后的值,但不会在输入中显示更新后的值。 errorMessages
在 Powerapp 应用程序中,我有屏幕,其中包含 1:“文本输入”,输入城市名称 2 : 当我点击清除按钮时,如何清除文本输入的值? Click here for more details of
我是一名优秀的程序员,十分优秀!