2017-07-14 83 views
0

大家好,我是新來的來回應本機我只是盯着學習。React native不會顯示來自其他js文件的視圖

我與試圖反應本地人,我已經研究過它,現在我正在努力學習它,這是我第一天在此,

我剛剛創建反應過來本地項目,並創建了一個js文件和寫視圖中創建JS和index.android.jd導入,但它顯示默認視圖

這裏是代碼

index.android.js

import React, { Component } from 'react'; 
import { 
AppRegistry, 
StyleSheet, 
Text, 
View 
} from 'react-native'; 
import Compo from './homecomponent' 
export default class AwesomeProject extends Component { 
render() { 
return (
    <Compo/> 
); 
} 
} 

AppRegistry.registerComponent('AwesomeProject',()=> AwesomeProject);

和homecomponent是遵循

import { 
AppRegistry, 
StyleSheet, 
Text, 
View, 
ToolbarAndroid, 
TouchableHighlight 
} from 'react-native'; 

export default class homecomponent extends Component 
{ 
render() 
{ 
    return(

<view style={styles.container}> 
    <ToolbarAndroid style={styles.toolbar0} 
    title="counter demo"/> 
<Text>WOWWWW</Text> 
<TouchableHighlight 
style={ styles.button} > 
    <Text style={styles.buttontext}>increment</Text> 
    </TouchableHighlight> 
</view> 
     ); 
} 
} 

const styles = StyleSheet.create({ 
container: { 
flex: 1, 
justifyContent:'center', 
alignItems: 'center', 

}, 
button:{ 
backgroundColor:'deepskyblue', 
borderwidth:1, 
alignItems:'center', 
justifyContent:'center', 
alignSelf:'stretch', 
height:50, 
margin:10, 
borderRadius:3 
}, 

buttontext:{ 
fontSize:20, 
color:'#FFF' 
}, 
toolbar: { 
    alignSelf: 'stretch', 
    height: 50, 
    backgroundColor: 'silver', 
}, 
text: { 
    fontSize:20, 
}, 
cancelButton: { 

    backgroundColor: '#696969', 
}, 
}); 

請給我suggesction爲什麼認爲不android.I更新停留在從早上這個問題。從 './HomeCompo'

+0

嘗試通過更改此行'從/.component'導入Compo從'./homecomponent'導入homecomponent;' –

回答

0

進口homecomponent執行這兩個以下的事情:

首先,在index.android.js文件,從 './homecomponent'到更新進口康波從'./homecomponent'導入homecomponent

其次,在同一個文件中,更新你的視圖內的返回組件。只需添加視圖並在其中將組件名稱重命名爲家庭組件

+0

已更新question.but給出解決方案也不工作不工作 –

0