小编Ayu*_*ava的帖子

如何在反应中使用onload?

要在 onload 上运行 imagesrore 函数,我必须调用<img src="image_7.jpg" className="hide" alt="image_7.jpg"/>image 但实际上没有使用此行,如果我删除此 onload 则不起作用,并且不会调用该函数。那么如何在反应中调用 imagestore() onload 呢?

class PicturesList extends React.Component {
        constructor(props) {
          super(props);
          this.state = {
          imagesarray: []
          };
          this.imagestore = this.imagestore.bind(this);
        }
        render() {
          return (
          <div>
            <div onLoad= {() => this.imagestore()}>
                <img src="image_7.jpg" className="hide" alt="image_7.jpg"/>
                // To run the imagesrore function onload I have to call this image but actually there is no use of this line and if I remove this onload doesn't work and function …
Run Code Online (Sandbox Code Playgroud)

reactjs

12
推荐指数
2
解决办法
7万
查看次数

标签 统计

reactjs ×1