2017-10-17 172 views
0

所以我是新的反應原生,我遵循此tutorial video,我似乎無法導入'Splash'組件。不能導入組件反應原生

這是錯誤消息我得到

錯誤消息 enter image description here

這是我寫

import React, { Component } from 'react'; 
import { 
    Platform, 
    StyleSheet, 
    Text, 
    View, 
    Image, 
    TextInput, 
} from 'react-native'; 

import Splash from './splash'; 


export default class App extends Component<{}> { 
    render() { 
    return (

     <Splash/> 
    ); 
    } 
} 

代碼和組件我想導入

import React, { Component } from 'react'; 
import { View, Text } from 'react-native'; 

export default class Splash extends Component { 
    render() { 
     return(
      <View style={styles.wrapper}> 
       <View style={styles.titleWrapper}> 
        <Text style={styles.title}>Hello World!</Text> 
       </View> 
       <View> 
        <Text style={styles.subtitle}>Powered by React 
Native</Text> 
       </View> 
      </View> 
     ); 
    } 

} 

const styles = Stylesheet.create({ 
    wrapper: { 
     backgroundColor: 'red', 
     flex: 1, 
     justifyContent: 'center', 
     alignItems: 'center' 
    }, 

    title: { 
     color: 'white', 
     fontSize: 35, 
     fontWeight: 'bold', 
    }, 

    subtitle: { 
     color: 'white', 
     fontWeight: '200', 
     paddingBottom: 20 

    }, 

    titleWrapper: { 
     justifyContent: 'center', 
     flex: 1 
    } 
}); 

任何幫助會很大讚賞。

回答

0

有兩種解決方案可以做。
1)你有沒有試過重新運行你的模擬器。有時你只需要重新運行模擬器,因爲它在第一次運行時不會拾取文件。
2)import Spalsh from './Splash你需要大寫你的Splash
3)檢查你的文件路徑飛濺。它最有可能不正確。

+0

對,就是這樣,我需要大寫'Splash',並用StyleSheet修正一個錯字 –