import Taro, { Component } from '@tarojs/taro' import { View } from '@tarojs/components' import classnames from 'classnames' import './index.scss' type WantProps = { onClickMask?: () => void } type DefaultProps = { show: boolean } type IProps = WantProps & DefaultProps class XcMask extends Component { static defaultProps: DefaultProps = { show: false } handleMaskClick = () => { const { onClickMask } = this.props onClickMask && onClickMask() } render () { const { show } = this.props const maskClassNames = classnames('xc-mask', { 'xc-mask--show': show }) const maskInterlayerClassNames = classnames('xc-mask__interlayer', { 'xc-mask__interlayer--show': show }) return ( {/* interlayer 用于触发对mask区域的点击,为了避免mask在关闭的动画过程中,用户再次点击仍然触发handleMaskClick */} {this.props.children} ) } } export type Props = WantProps & Partial export default XcMask