当我尝试这段代码时,它显示了这个奇怪的错误。最有趣的部分是渲染方法没有任何变化。除非我在视图中添加mapvew,否则它工作得很好。这是代码:
import React, {Component} from "react";
import {View, Image, MapView} from "react-native";
import {
Container,
Header,
Content,
Footer,
FooterTab,
Button,
Icon,
Text,
Left,
Right,
Body,
Title,
Thumbnail,
Grid,
Row,
Col,
} from "native-base";
import typographystyles from '../styles/typographystyles';
import { primary, secondary } from '../styles/variables';
class PostScreen extends Component {
render() {
return (
<Container style={styles.container}>
<Content>
<View>
<Grid>
<Row>
<Col style={styles.col} >
<Text style={typographystyles.heading1}> Jennifer </Text>
<Text style={{marginTop:-20, fontSize:16, marginLeft:15}}> Vew and Edit Profile </Text>
</Col>
<Col style={styles.col}>
<Thumbnail style={{marginTop:20}} source={require("../img/profile2.jpg")}/ >
</Col>
</Row>
</Grid>
</View>
<View style={{marginLeft:15, marginBottom:20}}>
<Text style={{marginTop:10,marginBottom:10, fontSize:18}}> 90 EUR per night </Text>
</View>
<Text style={{marginLeft:5, marginRight:5}}>
Lorem ipsum dolor sit amet, eum iisque accommodare cu, ex enim eligendi appareat nec. Magna quando aliquid mel ea, exerci nonumes maiestatis eum ei, harum possim sed ut. Mea omnis bonorum posidonium ne, pri ne illud suavitate assentior. His choro numquam ad, mei te integre vituperatoribus. An vim nobis similique theophrastus, mazim mandamus assentior pro id.
Ad bonorum senserit postulant eum, quo et virtute feugiat. Reque laudem referrentur ex mei. Eu vel dico sonet iudicabit. Eos et falli fabulas, eam quis timeam voluptatum ea. Nullam persequeris ne nec. Reque error vivendum sit id, te sit partem aeterno feugait.
</Text>
<View style={{flex: 1}}>
<MapView
style={styles.map}
showsUserLocation={true}/>
</View>
</Content>
</Container>
);
}
}
const styles = {
img: {
height:200,
width: null,
flex:1,
},
col:{
marginTop:30,
justifyContent: "center",
alignItems: "center",
},
map:{
flex:1
},
}
export default PostScreen;
这段代码有什么问题?怎么修好? 正如我所说,它是在尝试添加mapvew后才引起的。
提前致谢:)
答案 0 :(得分:2)
反应原生sdk中没有MapView组件。
您必须从Here
安装或者,如果您使用expo创建了自己的应用,只需使用提及的import { MapView } from 'expo';
<form action="/flight_ticket/book" name="myform" method="post">
.
.
.
Enter the number of tickets to be booked:
<input name="nooftickets" type="text"><br/><br/>
<a href="#" id="names" onclick="addFields();">Enter names</a>
<div id='container'/>
</div>
<br/><br/>
</form>
</body>
进行导入