update 大量细节处理
This commit is contained in:
@@ -11,14 +11,14 @@ const getSrc = async (id) => {
|
||||
return ''
|
||||
}
|
||||
|
||||
let id = ''
|
||||
|
||||
export default class Image extends Component {
|
||||
|
||||
state = {
|
||||
src: ''
|
||||
}
|
||||
|
||||
id = ''
|
||||
|
||||
constructor(props) {
|
||||
super(props)
|
||||
|
||||
@@ -31,15 +31,15 @@ export default class Image extends Component {
|
||||
}
|
||||
|
||||
componentDidUpdate() {
|
||||
if (id !== this.props.id && this.props.id) {
|
||||
if (this.id !== this.props.id && this.props.id) {
|
||||
this.setSrc()
|
||||
}
|
||||
}
|
||||
|
||||
setSrc = async () => {
|
||||
if (this.props.id) {
|
||||
id = this.props.id
|
||||
const src = await getSrc(id)
|
||||
this.id = this.props.id
|
||||
const src = await getSrc(this.id)
|
||||
this.setState({ src })
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user