alkhatibdev/inertia-pagination

Laravel Inertia Pagination,是一个用于生成 Inertia 分页 Vue 组件的 Laravel 扩展包,设计时采用了 TailwindCSS。

0.0.1 2023-11-30 22:41 UTC

This package is auto-updated.

Last update: 2024-09-06 11:59:06 UTC


README

Latest Version MIT Licensed

介绍

Laravel Inertia Pagination,是一个用于生成 Inertia 分页 Vue 组件的 Laravel 扩展包,设计时采用了 TailwindCSS。

安装

通过 Composer 安装

composer require alkhatibdev/inertia-pagination

发布

php artisan vendor:publish --tag=inertia-pagination

使用方法

假设这是您的 inertia 响应

// App\Http\Controllers\PostController

public function index() 
{
    return Inertia::render('Post/Index', [
        'posts' => Post::select([
            "id", "title", "description"
        ])->paginate(10),
    ]);
}

在您的 inertia 页面中,只需导入 IPagination Vue 组件,然后将分页集合链接传递给它。

// resources/js/Pages/Post/Index.vue 

<script setup>
    import IPagination from '@/Components/vendor/InertiaPagination/IPagination.vue'

    defineProps({
        posts: Object
    })
</script>

<template>
    ...
        <div v-for="post in posts.data" :key="post.id">...</div>

        <!-- Use component here, and pass the links array -->
        <IPagination :links="posts.links" />
    
    ...
</template>

自定义

即将推出..

许可证

语言切换器是开源软件,使用 MIT 许可证许可,详情请见 MIT 许可证