javascript - localStorage 在 TouchableOpacity 标签中不起作用
问题描述
我想同时使用localStorage并移动到另一个页面,但只移动工作,我无法获得价值
const pressHandlerMapTest = () => {
navigation.navigate("TestMapScreen");
};
return (
<ImageBackground style={styles.background}>
<View style={styles.tourWindow}>
<TouchableOpacity underlayColor="red"
onPress={pressHandlerMapTest}
onPressIn={() => {
localStorage.setItem('tour', 'others');
}}>
<Image source={require("../assets/royals.png")} ></Image>
</TouchableOpacity>
</View>
</ImageBackground>
);
解决方案
const pressHandlerMapTest = () => {
localStorage.setItem('tour', 'others');
navigation.navigate("TestMapScreen");
};
return (
<ImageBackground style={styles.background}>
<View style={styles.tourWindow}>
<TouchableOpacity underlayColor="red"
onPress={pressHandlerMapTest}
>
<Image source={require("../assets/royals.png")} ></Image>
</TouchableOpacity>
</View>
</ImageBackground>
);
推荐阅读
- hibernate - SQLCODE=-206,SQLSTATE=42703,SQLERRMC=SEQNAME,驱动程序=4.8.86
- css - 指向不同页面的链接
- java - 我收到 AsyncTask.java 的以下错误
- java - JavaFX - css 在我的项目中不起作用,但可以在场景构建器中工作
- mysql - 更改密码后仍然得到:用户'root'@'localhost'的访问被拒绝(使用密码:是)
- firebase - 为什么 Firebase Firestore 每隔一分钟触发一次查询?
- javascript - 从无限的while循环中中断,为什么这段代码不起作用
- javascript - 有没有办法将 Jquery 元素存储在 HTML5 数据属性中?
- r - 将自定义函数应用于每一行仅使用参数的第一个值
- ios - Swift UIView 内存使用和处理许多子视图