如何在react中使用inertia在laravel上分页
提取分页数据:
$contacts = Contact::orderBy('name', 'asc')->paginate(10);
return Inertia::render('Contacts/index', [
'contacts' => $contacts
]);我知道如何在blade ({{ $contacts->links() }})中呈现链接,但有没有办法在inertia上这样做,还是需要为分页链接制作自己的组件?
发布于 2022-04-29 07:33:33
最简单的方法是用链接创建自己的组件(这些链接仍然存在)。
这是vue中的一个例子,但应易于移植以作出反应:
<template>
<div>
<div class="flex flex-wrap -mb-1">
<template v-for="(link, key) in links" :key="key">
<div v-if="link.url === null" class="mr-1 mb-1 px-4 py-3 text-sm leading-4 text-gray-400 border rounded"
v-html="link.label" />
<inertia-link v-else
class="mr-1 mb-1 px-4 py-3 text-sm leading-4 border rounded hover:bg-white focus:border-indigo-500 focus:text-indigo-500"
:class="{ 'bg-blue-700 text-white': link.active }" :href="link.url" v-html="link.label" />
</template>
</div>
</div>
</template>
<script>
export default {
props: {
links: Array
},
}
</script>发布于 2022-04-29 12:03:17
你可以尝试这样做,以获得更好的反应:-
import DataTable from "react-data-table-component";
<DataTable
style={{ background: "transparent" }}
title="User"
columns={columns}
data={allData}
defaultSortFieldId={1}
sortIcon={<ArrowUpwardIcon />}
pagination
/>https://stackoverflow.com/questions/72053504
复制相似问题