【发布时间】:2017-09-28 19:25:33
【问题描述】:
我正在尝试将AsyncStorage 中的数据保存在react-native 中。我想异步保存它,所以使用async 和await 关键字。
async onPositiveClickListener = () => {
// user has completed product tour_end
try {
await AsyncStorage.setItem("@ProductTour:key", "true");
const { navigate } = this.props.navigation;
navigate("DashboardScreen");
} catch (error) {
console.log(error);
}
};
保存程序时出错
SyntaxError: Unexpected token, expected ( (40:32)
38 | };
39 |
> 40 | async onPositiveClickListener = () => {
| ^
41 | // save user has completed product tour_end
42 | try {
43 | await AsyncStorage.setItem("@ProductTour:key", "true");
Hide Stack Trace
SyntaxError: Unexpected token, expected ( (40:32)
38 | };
39 |
> 40 | async onPositiveClickListener = () => {
| ^
41 | // save user has completed product tour_end
42 | try {
【问题讨论】:
标签: javascript react-native async-await react-native-android