1.引入FlatList组件
import { FlatList } from 'react-native';
2.编写列表组件
class DeviceList extends Component {
//转换时间戳
getTime = (timeStamp) => {
var date=new Date(parseInt(timeStamp)* 1000);
var year=date.getFullYear();
var mon = date.getMonth()+1;
var day = date.getDate();
var hours = date.getHours();
var minu = date.getMinutes();
var sec = date.getSeconds();
return mon+'-'+day;
}
render() {
return (
<FlatList
data={this.props.deviceList}
keyExtractor={(item, index) => index.toString()}
renderItem={({item,index}) => {
return (
<View style= {
{paddingLeft: 20,paddingRight: 20,paddingTop:15,paddingBottom: 15,borderBottomColor: "#ddd",borderBottomWidth: 1}}>
<View style={
{f