import * as React from 'react'; import './scss/index.scss'; import NormalTag from './NormalTag'; import CountTag from './CountTag'; import { TagProps } from './interface'; type TagPropsWhithDeafult = TagProps & { afterClose: (id: number) => void; // 关闭标签的回调 afterCountOperation: (id: number, praise: boolean) => {} } export default class Tag extends React.Component { static defaultProps = { id: 1, title: 'Tagss', type: 'normal', bgOpacity: 0.2, color: '#ED5858', size: 'large', count: 10, countOperation: false, praise: true, afterCountOperation: (id: number, praise: boolean) => { }, close: false, afterClose: (id: number) => { } } afterClose = (id: number) => { let { afterClose } = this.props as TagPropsWhithDeafult; afterClose(id) } afterCountOperation = (id: number, praise: boolean) => { let { afterCountOperation } = this.props as TagPropsWhithDeafult; afterCountOperation(id, praise) } render() { let { type, id, title, color, bgOpacity } = this.props; switch (type) { case 'count': return default: return } } }