import {Component} from 'react'; import './index.less'; import {render} from 'less'; export default class MyDiv extends Componet{ constructor(props){ super(props); this.state = { content : props.news }; } nextPage = () =>{ this.state.content.nextPage && this.state.content.nextPage(); } render(){ return ( <div className = "my-div"> <div className = "my-div-top"> <div className = "mydiv-top-title"{this.state.content.name}></div> <div className = "mydiv-top-right"><a onClick = {this.nextPage}> 下一页 </a> </div> </div> <div className = "my-div-content"> { (this.state.content.list || []).map((item,index) = > { return ( <div className = "my-div-content-line"><a href = "javascript:;" onClick = {() => { this.state.content.openUrl(index);}}>{item.title}</a><div>) ) })} </div> </div> ) } }