【发布时间】:2021-07-14 04:25:02
【问题描述】:
在控制器中:
public function index(Request $request, $id) {
if (!empty($id)) {
$product = product::select('name', 'price', 'quantity')
->where('id', $id)
->get()->toArray();
return response()->json($product);
}
}
在Vue中,我使用Axios获取数据。
axios
.get("/api/product", {
params: {
id: id,
},
})
.then((res) => {
this.rows = res.data;
})
.catch((error) => {
console.log(error);
});
它显示列表没问题 但我不希望它获取所有数据..但是通过分页,一键分页它将加载 30 个项目。给我一些想法,谢谢。
【问题讨论】: