我運行我的應用程序時出現「意外令牌,預計}」錯誤。 我試圖尋找這個問題,但找不到解決方案。 好像一切都在這裏確定:意外令牌,預計}
import React from 'react';
import { Platform, StyleSheet, Button } from 'react-native';
import Ionicons from 'react-native-vector-icons/Ionicons';
import { TabNavigator } from 'react-navigation';
const myNavScreen = ({navigation})=>(
<View style={styles.container}>
<Button onPress={()=>navigation.navigate("Home")}
title="Go to Home"/>
<Button onPress={()=>navigation.navigate("Friends")}
title="Go to Friends"/>
<Button onPress={()=>navigation.goBack(null)}
title="Go Back"/>
<View/>
);
const MyHomeScreen = ({navigation})=>(
<myNavScreen navigation={navigation}/>
);
MyHomeScreen.navigationOptions={
tabBarLabel: 'Home',
tabBarIcon: ({tintColor, focused}) =>(
<Ionicons
name={focused? 'ios-home' : 'ios-home-outline'}
size={26}
style={{color: tintColor}}
/>
),
};
const MyFriendsScreen = ({navigation})=>(
<myNavScreen navigation={navigation}/>
);
MyFriendsScreen.navigationOptions={
tabBarLabel: 'My Friends',
tabBarIcon: ({tintColor, focused})=>(
<Ionicons
name={focused? 'ios-people' : 'ios-people-outline'}
size={26}
style={{color: tintColor}}
/>
),
};
const SimpleTabs = TabNavigator({
Home:{
screen: MyHomeScreen,
path:'',
},
Friends:{
screen: MyFriendsScreen,
path: 'cart',
},
},
{
tabBarOptions:{
activeTintColor: Platform.OS === 'ios' ? '#e91e63' : '#fff',
},
}
);
const styles = StyleSheet.create({
container: {
marginTop: Platform.OS === 'ios' ? 20 : 0,
},
});
export default SimpleTabs;
這是說,問題出在MyHomeScreen.navigationOptions
塊,但試圖刪除它只是造成另一個代碼塊同樣的問題。 我在尋找失蹤}或其他語法錯誤但找不到任何東西。
我在這裏錯過了什麼?
後面的逗號... –
@JeffMercado感謝,但它不工作。 –
哦,我的錯誤,但問題似乎在'myNavScreen'函數。標記無效,「View」的close標記不是關閉標記。 –