刚开始学React-Native , 无法使用Import
import React, { Component } from 'react';
import {
AppRegistry,
StyleSheet,
Text,
Image,
View
} from 'react-native';
export default class Logo extends Component{
render(){
let pic = {
uri: 'https://upload.wikimedia.org/wikipedia/commons/d/de/Bananavarieties.jpg'
}
return (
<View style={logo_styles.container}>
<Image source={pic} style={{width: 193, height: 110}} />
</View>
);
}
}
const logo_styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: 'center',
alignItems: 'center',
backgroundColor: '#F5FCFF',
},
});
在index.android.js中,写
/**
* Sample React Native App
* https://github.com/facebook/react-native
* @flow
*/
import React, { Component } from 'react';
import {
AppRegistry,
StyleSheet,
Text,
TextInput,
Image,
View
} from 'react-native';
import Logo from "Logo"
export default class zz extends Component {
render(){
return <Logo />;
//return <Welcome2 name="HHHHH" />
}
}
AppRegistry.registerComponent('zz', () => zz);
但如下错误
经过了多方查找,发现错误在这里
import Logo from "./Logo"
这对习惯了当前路径就在编译路径下的人。。就是个坑。。。
好吧,我菜!!!