import * as React from "react"; import PropTypes from 'prop-types'; type defaultProps = { title: '标题',//标题 subtitle: '阿房女',//副标题 bgColor: '#fff',//背景颜色,16进制 pos: 1,//位置,1:居左,2:居中,3:居右 linkText: '方法好v', //链接文本 link: 'http://www.baidu.com',//导航链接 } type ContentData = { title: string,//标题 subtitle: string,//副标题 bgColor: string,//背景颜色,16进制 pos: number,//位置,1:居左,2:居中,3:居右 linkText: string, //链接文本 link: string,//导航链接 } & defaultProps interface LPData { content: Array, [propsName: string]: any } interface LPType { content: any, [propsName: string]: any } type IPropTypes = { source?: ContentData, [propsName: string]: any } const CLASS = 'm-title-'; class MPro extends React.Component { state: any; constructor(props: IPropTypes) { super(props); this.state = { linkData: "" } } componentDidMount(): void { if (this.props.linkType == 1) { // let link= Util.getGoodsLink(this.props.id) this.setState({ linkData: "http://www.baidu.com" }) } } componentWillReceiveProps(nextProps, nextContext) { if (nextProps.linkType == 1) { // let link= Util.getGoodsLink(nextProps.id) this.setState({ linkData: "http://www.baidu.com" }) } } render() { let source = this.props; let content = source; return (
{ content && (content.title || content.subtitle) ?

{content.title} { content.linkText ? {"-" + content.linkText} : '' }

{ content.subtitle ? {content.subtitle} : "" }
: '' }
); } } export default MPro;