我有以下基本的反应本机代码:
import React from 'react';
import {StyleSheet, View, Image} from 'react-native';
//images
import login_blueGirl from './assets/images/login_blueGirl.png';
const App = () => {
return (
<>
<View style={styles.container}>
<Image source={login_blueGirl}></Image>
</View>
</>
);
};
const styles = StyleSheet.create({
container: {
flex: 1,
flexDirection: 'column'
}
});
export default App;
I'm getting a Cannot find module './assets/images/login_blueGirl.png'
. When I type ./
VSCode give me however the autocomplete option:
为什么会这样呢?
That's not quite how you're supposed to be importing images, use
require
instead.