react 每2秒调用一次函数

源码:

  componentDidMount() {

    //生命钩子,组件被挂在后调用

    this.func ();

  }

func = () => {

    setInterval(() => {

     alert("每2秒就调用一次函数");

    }, 2000);

  }

发布了98 篇原创文章 · 获赞 19 · 访问量 10万+

猜你喜欢

转载自blog.csdn.net/water_Popcorn/article/details/103251779