//在util包下创建Detail.js
import React, { Component } from "react";
import { ScrollView, Dimensions } from "react-native";
import HTML from "react-native-render-html";
export default class Detail extends Component {
//配置标题
static navigationOptions = ({ navigation }) => {
let item = JSON.parse(navigation.getParam("item"));
return {
title: item.title
};
};
constructor(props) {
super(props);
this.state = {
//获取路由传递过来的数据
item: JSON.parse(this.props.navigation.getParam("item"))
};
}
render() {
return (
<ScrollView style={{ flex: 1, padding: 10 }}>
<HTML
html={this.state.item.content}
imagesMaxWidth={Dimensions.get("window").width}
/>
</ScrollView>
);
}
}