【发布时间】:2021-07-04 12:05:22
【问题描述】:
我正在构建一个 laravel vue 应用程序,我想从我的类别控制器呈现我的类别
这是我的类别控制器
public function index()
{
// geeting all the categories
$categories = Category::all();
return response([ 'categories' => CategoryResource::collection($categories), 'message' => 'Retrieved successfully'], 200);
}
这是我的 category.vue 文件
<tbody>
<tr v-for="category in categories.data" :key="category.id">
<td>{{ category.id }}</td>
<td>{{ category.name }}</td>
<td>11-7-2014</td>
<td><span class="tag tag-success">Approved</span></td>
</tr>
</tbody>
这也是我在 category.vue 文件中加载类别的方法
loadCategory(){
axios.get("api/category").then(({ data }) => (this.categories = data));
},
现在我没有任何错误,但它也没有呈现我的类别。请需要帮助
【问题讨论】: