是否可以在 yii2 中全局更改 gridview 分页按钮计数?

Is it possiable to change gridview pagination button count globally in yii2?

这很完美。但是,我想将此寻呼机设置全球化

GridView::widget([
    'dataProvider' => $dataProvider,
    'pager' => [
        'maxButtonCount' => 5,
        'options' => [
            'tag' => 'ul',
            'class' => 'pagination pagination-sm',
        ]
    ],
    'columns' => .....   
]);

我的代码是在组件部分。但是,它不起作用。

'components' => [
    .....

    'pager' => [
        'class' => yii\widgets\LinkPager::class,
        'maxButtonCount' => 5,
        'options' => [
            'tag' => 'ul',
            'class' => 'pagination pagination-sm',
        ]
    ],
],   

我找到了全局处理分页按钮计数的解决方案

$config = [
    ....
    'container' => [
        'definitions' => [
            'yii\widgets\LinkPager' => [
                'maxButtonCount' => 6,
                'options' => [
                    'tag' => 'ul',
                    'class' => 'pagination', //pagination-sm
                ]
            ],
        ],
    ],
    'components' => [
        ...
    ],
];