关于错误:Cannot read property 'then' of undefined?
发布于 5 年前 作者 sxu 8887 次浏览 来自 问答

我的需求是:下拉刷新后,在console打印出“OK”,并停止下拉刷新的动画。

然后我想使用promise回调实现,结果报错了。我觉得应该是onPullDownRefresh( )的“then”和_getData( )的“then”冲突了,但我就是想在onPullDownRefresh( )里面调用_getData( ),然后使用promise回调实现我的需求。请问能做到吗?如果能,该怎么改代码呢?请大佬指点

1 回复

_getData(){

    return products.get().then(res=>{

        this.setData({

            product:res.data

        })

        return Promise.resolve(res)

    })

}

回到顶部