我正在使用vuejs进行前端和Laravel后端的网站上实现分页功能。目的是使用户能够使用下拉框选择每页显示的项目数。注意:我正在使用paginate(perPage,10)。因此,我试图解决如何从Vue前端获取“ perPage”并使用新的perPage值刷新页面的问题。在此先感谢!
**$projects = DB::table('projects')
->select("projects.*", "project_countries.project_id",
DB::raw("(GROUP_CONCAT(countries.name SEPARATOR ',')) as 'countries'"))
->join('project_countries', 'projects.project_id', '=', 'project_countries.project_id')
->join('countries', 'project_countries.country_id', '=', 'countries.id')
->groupBy('project_countries.project_id')
->orderBy('project_countries.project_id')
->paginate($request->get('per_page', 10));**
这是我在Vue上的数据:
data() {
return {
projects: [],
project: {
id: '',
project_id: '',
title: '',
amount: '',
countries: '',
gcf_date: ''
},
project_id: '',
pagination: {},
edit: false,
perPage: 10,
}