分页无法正常工作 - will_paginate,bootstrap4

Pagination does not work properly - will_paginate, bootstrap4

我是 Rails 的新手。尝试在我的项目中添加 will_paginate,按照说明进行操作并相应地添加配置。最后它工作并显示页码。

1.) 问题是,当它显示页码和下一页选项时,它不包括数字之间的 space。

2.) 有什么方法可以将 will_paginate bootstrap 与 bootstrap 4 一起使用吗? bkz,据我所知,那个人提到他不再对此提供支持 gem。

is there any way to use will_paginate bootstrap with bootstrap 4? bkz as i know the guy mentioned he dont provide support for that gem anymore.

这是 will_paginatebootstrap 4 will_paginate-bootstrap4

的支持

您遇到的问题与Ruby/Rails完全无关:这只是一个CSS问题。 will_paginate 不假设分页部分的样式,只是输出无样式的 HTML 标签。然后,您有责任根据自己的喜好设计样式 - 例如Bootstrap,就像你提到的那样。

一般来说,我建议使用 Kaminari 而不是 will_paginate:我认为分页解决方案使用常规模板而不是使用助手呈现所有 HTML 更有意义方法。但这只是我使用 will_paginate 十多年和 Kaminari 几乎自 6 1/2 年前问世以来的看法。

因为你可以看到数字,所以你的 bootstrap 4 似乎已经在工作了,你只需要制作 CSS 样式来使这些分页链接更漂亮,这里是来源 css for will_paginate

自定义其查看方式下面是示例或 will_paginate scss 文件 你可以在 app/stylesheets/will_paginate.scss 中创建一个 scss 文件并将代码放在下面

.digg_pagination {
  background: #FFFFFF; 
  font-size: 1.2em;
  cursor: default;
  /* self-clearing method: */ }
  .digg_pagination a, .digg_pagination span, .digg_pagination em {
    padding: 0.2em 0.5em;
    display: block;
    float: left;
    margin-right: 1px; }
  .digg_pagination .disabled {
    color: #999999;
    border: 1px solid #dddddd; }
  .digg_pagination .current {
    font-style: normal;
    font-weight: bold;
    background: #2e6ab1;
    color: white;
    border: 1px solid #2e6ab1; }
  .digg_pagination a {
    text-decoration: none;
    color: #105cb6;
    border: 1px solid #9aafe5; }
    .digg_pagination a:hover, .digg_pagination a:focus {
      color: #000033;
      border-color: #000033; }
  .digg_pagination .page_info {
    background: #2e6ab1;
    color: white;
    padding: 0.4em 0.6em;
    width: 22em;
    margin-bottom: 0.3em;
    text-align: center; }
    .digg_pagination .page_info b {
      color: #000033;
      background: #6aa6ed;
      padding: 0.1em 0.25em; }
  .digg_pagination:after {
    content: ".";
    display: block;
    height: 0;
    clear: both;
    visibility: hidden; }
  * html .digg_pagination {
    height: 1%; }
  *:first-child + html .digg_pagination {
    overflow: hidden; 
}