import * as React from 'react'; import './style.scss'; // 组件内容样式 interface CustomCmpProps { title: string; backgroundImage: string; imgCount: number; commentCount: number; data?: any; } export default class CustomCmp extends React.PureComponent { constructor(props: CustomCmpProps) { super(props); this.agreeDataFormat = this.agreeDataFormat.bind(this); } agreeDataFormat(agreeData: number) { if (agreeData && agreeData <= 9999) { return agreeData; } if (agreeData && agreeData > 9999) { return `${Math.floor(agreeData / 1000) / 10}w`; } return ''; } render() { const { title, backgroundImage, imgCount, commentCount } = this.props; console.log('当前自定义组件:', this.props, this); const curBackgroundImage = backgroundImage || 'https://custom-widgets.bj.bcebos.com/amis-cmp-cli.jpg'; return (
{title || '全场景智能业务管理系统,助力企业构建数字化客户管理平台,推动业务持续增长。'}
{imgCount > 0 &&
{imgCount}
}
Amis · 低代码平台
{commentCount && commentCount > 0 && (
{this.agreeDataFormat(commentCount)}评
)}
); } }