react-native - 我怎样才能发送我的输入值通过 onSubmitEditing 到异步函数?
问题描述
我想在本机反应中保存字段输入的值。如何使用onSubmitediting
事件将值发送到异步函数?
我试过这个:
<TextInput onSubmitEditing={ (text) => this.Store(text)}></TextInput>
这是我正在使用的功能
Store = async() =>
{
var textvalue = "here the value of the <TextInput>";
try
{
await AsyncStorage.setItem('@Temp:city', textvalue );
}
catch (error)
{
console.log(error)
}
}
解决方案
Please try this:
<TextInput
onSubmitEditing={ event => {
const text = event.nativeEvent.text;
this.Store(text);
}} >
</TextInput>
And save like this:
Store = async(text) => {
try
{
await AsyncStorage.setItem('@Temp:city', text );
}
catch (error)
{
console.log(error)
}
}
推荐阅读
- python - 使用 selenium 和 python 实现 google 的自动化
- azure - 使用链接访问 Azure Data Lake Container
- phpoffice-phpspreadsheet - PHPSpreadSheet 无法找到电子表格中存在的“命名范围”
- powershell - 在日志文件中的连续行中搜索多个字符串
- php - 在 Halk Bank Payment Gateway For Woocommerce 中将订单总额转换为默认货币
- java - 如何摆脱招摇 ui 响应中的示例值
- css - Shinydashboard 侧边栏初学者问题——要点
- html - 只有一个出现在屏幕上的元素
- javascript - Flask:如何通过分页过滤和显示不同的 CRUD 表?
- python - 网络摄像头视频是黑白 Python 代码