From 1d395e6d750fe91082c99a15e355ab2841ed65c6 Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期四, 04 一月 2024 17:49:21 +0800 Subject: [PATCH] 2024-01-04 --- src/components/mkPicture/index.jsx | 17 +++++++++++++---- 1 files changed, 13 insertions(+), 4 deletions(-) diff --git a/src/components/mkPicture/index.jsx b/src/components/mkPicture/index.jsx index e4b8f39..6ddb479 100644 --- a/src/components/mkPicture/index.jsx +++ b/src/components/mkPicture/index.jsx @@ -9,6 +9,7 @@ class MkPicture extends Component { static propTpyes = { style: PropTypes.object, + lostTip: PropTypes.bool, scale: PropTypes.bool, url: PropTypes.string, urls: PropTypes.array, @@ -20,24 +21,26 @@ } UNSAFE_componentWillMount() { - const { url } = this.props + const { url, lostTip } = this.props if (url) { this.setState({url: url, lost: false}) this.checkUrl(url) } else { - this.setState({url: LostPng, lost: true}) + this.setState({url: lostTip ? LostPng: '', lost: true}) } } UNSAFE_componentWillReceiveProps (nextProps) { + const { lostTip } = this.props + if (nextProps.url) { if (nextProps.url !== this.state.url) { this.setState({url: nextProps.url, lost: false}) this.checkUrl(nextProps.url) } } else { - this.setState({url: LostPng, lost: true}) + this.setState({url: lostTip ? LostPng: '', lost: true}) } } @@ -63,9 +66,15 @@ } render() { - const { style, scale, urls } = this.props + const { style, scale, urls, lostTip } = this.props const { url, lost } = this.state + if (!lostTip && !url) { + return ( + <div className="ant-mk-picture empty" style={style}></div> + ) + } + return ( <div className={'ant-mk-picture' + (scale ? ' scale' : '') + (lost ? ' lost' : '')} -- Gitblit v1.8.0