2017-10-17 229 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修正一个错字 –