获取到api的数据,需要render 到datatable 上的时候出错,
取到的数据:是一个object
{"pool":[
{"pool_id":"2","libraries_library_id":"2"},
{"pool_id":"1","libraries_library_id":"1"}
]}
刷新页面:
PoolsDisplayComponent.html:5 ERROR TypeError: val.slice is not a function at DatatableComponent.set [as rows] (index.js:2803) at updateProp (core.js:12661) at checkAndUpdateDirectiveInline (core.js:12368) at checkAndUpdateNodeInline (core.js:13935) at checkAndUpdateNode (core.js:13878) at debugCheckAndUpdateNode (core.js:14771) at debugCheckDirectivesFn (core.js:14712) at Object.eval [as updateDirectives] (PoolsDisplayComponent.html:5) at Object.debugUpdateDirectives [as updateDirectives] (core.js:14697) at checkAndUpdateView (core.js:13844) ERROR CONTEXT DebugContext_ {view: {…}, nodeIndex: 6, nodeDef: {…}, elDef: {…}, elView: {…}}
原因:
api返回的数据是object,而render datatable需要的是一个array
Typically the error you see happens when the data you try to render in the table is not Array type.
So in your case you have the object { feedData: [...array of objects...] }
And you need it to be: [...array of objects...]