$grid ->column("index",'序号'); $grid->model()->collection(function (Collection $collection)use($grid){ $page = request('page')?:1; $startIndex = (($page-1)*$grid->perPage); foreach ($collection as $key=>$collect){ $collect->index =$startIndex+$key+1; } return $collection; });
只能这样写了,暂时不知道有啥更好的方法;