我正在尝试将一个静态图像从node js express服务到我的react本地应用程序。
我正试图使用express.static,但我发现了错误
失败的属性类型:提供给映像的属性源无效。
如何为React本机应用程序提供静态图像?
文件夹结构:
--public
-image.png
-app.js
App.JS
const app = express();
app.use(express.static('/public'));
app.get('/', (req, res) => res.status(200).send({
message: 'API Called',
}));
module.exports = app;
HeopePa.js
import React, {Component} from 'react';
import {AppRegistry, Text, View, TextInput, Button, StyleSheet, Image, } from 'react-native';
export default class HomePage extends Component{
constructor(){
super();
render(){
return(
<View style={styles.ViewStyle}>
<Image
style={styles.Image}
//{uri: this.getImage(item.teampicture1)}
source={{uri: 'http://192.168.1.10:8000/image.png'}}
/>
</View>
);
}
}