[Vue warn]: Invalid prop: type check failed for prop “data“. Expected Array, got Object 解决方法

1. Problem

The error message on the browser side is: Invalid attribute: The type check of the attribute "data" failed. It should be an array, but an object is sent from the backend

 Use the :data in the <el-table> attribute to bind, because tableData is of array type (Array), and the object type is transmitted from the backend, which is caused by data conversion during data binding

Binding in the method in <script> in vue

 

2. Solution

 After printing response.data.data, we know that the response.data.data returned by the background is an object, and the table needs an array, which means that the array should not be traversed, and the object can be pushed directly in the empty array. ie tableData.push(response.data.data);

 

 

Guess you like

Origin blog.csdn.net/qq_42514371/article/details/126478752