update 大量细节处理

This commit is contained in:
2021-06-17 18:07:33 +08:00
parent 5b57785b81
commit d3385102f2
12 changed files with 424 additions and 393 deletions

View File

@@ -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 })
}
}