/** * @author lvzhiyi * * @description img加载组件 */ import React, { Component } from 'react'; import './style.styl'; interface Props { src: string; place?: string; } interface State { error: boolean; } class Img extends Component { constructor(props: Props) { super(props); this.state = { error: false }; } render() { const { src, place } = this.props; return this.state.error && !place ? (
) : ( { this.setState({ error: true }); }} alt="" /> ); } } export default Img;