javascript - React Natvie 按钮和 textInput 不起作用
问题描述
由于<Modal>
React Native 中的 有点不确定,我自己制作了一个<View>
在 this.state.display 为 true 时呈现的。但是文本输入和按钮在单击/交互时不会做任何事情。
我尝试过使用常规<Modal>
但更喜欢我的方式。以及更改模态的实际样式。我添加了不同的 onPresses 和其他一些无效的小代码调整。
shouldRender() {
if (this.state.display) {
return (
<View style={styles.modal}>
<TextInput
placeholder="Event Title"
onChangeText={title => this.setState({title})}
value={this.state.title}
style={styles.textInput}
/>
<TextInput />
<Button />
<Button /> //the other buttons and textinput has similar things
</View>
);
} else {
return <View></View>;
}
}
在渲染方法中:
return(
<TouchableOpacity
onPress={this.addReminder}
style={styles.reminderTouch}>
<Text style={styles.reminderBtn}>+</Text>
</TouchableOpacity>
)
而 addReminder 方法只是将 this.state.display 设置为 true
我正在寻找提交/关闭模式和文本输入以更改标题和文本状态的按钮。现在,按钮在按下时没有动画,并且无法单击文本输入。
此外,在模态之前,当文本输入仅在屏幕上时,一切正常。
解决方案
您的描述听起来像是 zIndex 的问题 - 如果按钮不透明度和输入焦点不起作用,则会在您的模式顶部呈现一些东西。
我会尝试<View>{this.shouldRender()}</View>
在<View>
您的渲染方法中将zIndex
.
推荐阅读
- html - 如何使用
HTML表格中的标签
- python - 如何通过python检查postgres中的新条目?
- python - 如何根据数据框中的分隔符将字符串拆分为两个字符串
- python - mainloop 问题 python /raspberry pi / 基于沼泽冷却器恒温器
- excel - Excel 停止打印包含公式的空单元格
- vue.js - 更新 Vuex 状态对象并将项目作为道具传递给子组件正在增加内存
- c# - 如何在单个 PUT 方法中更新具有相同 id 的多行?
- python-3.x - 你知道为什么我的网格没有像我预期的那样工作吗?
- html - 为什么我的 ul 菜单没有延伸到窗口的末尾并且没有居中?
- .net - RazorLight RazorLight.TemplateNotFoundException:项目找不到带有密钥的模板