o.functionName is not a function
发布于 6 年前 作者 juan90 19615 次浏览 来自 问答

let data = [];

this.findById = function(id) {

    return data.find((d, index, arr) => {

        return d.id == id;

    });

};

data在api请求中更新。有时候会报thirdScriptError,o.find is not a function. ‘o.find’  is undefined.

报这个错误时,通常是在网络请求更新data数据时。

但是。。。即便是在更新数据,原有的data数据还是在的,怎么会报这个错误呢?

求大神指点!!

2 回复

数据请求是异步的,但是在请求完最后把新的数据赋值到data之前,data里是有原来数据的,怎么会报这样的错误呢,o.find is not a function. ‘o.find’  is undefined

data是数组,find函数应该是一只有的。

因为数据请求是异步的  然后这个方法已经执行了吧

回到顶部