Laravel 5.0 分页 render() 方法返回 HTML 文本

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/29728427/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-14 11:23:15  来源:igfitidea点击:

Laravel 5.0 Pagination render() method return HTML text

phplaravelpaginationlaravel-pagination

提问by azamuddin

I have a controller which send some product to the view. In the controller I paginated the data using

我有一个控制器,可以将一些产品发送到视图。在控制器中,我使用

...
// Controller code

Product::paginate(1) // because I only have 2 dummy data, 1 product per page
return view('product.index', compact('product'));

...

then in my product.index view I have the following code:

然后在我的 product.index 视图中,我有以下代码:

    <!-- Pagination link -->
    [[ $products->render() ]]
    <!-- End Paginatin link -->

The code works, but it return the HTML without being rendered by the browser as element. The resulting output is like below

该代码有效,但它返回 HTML 而不被浏览器作为元素呈现。结果输出如下

<ul class="pagination"><li class="disabled"><span>?</span></li> <li class="acti![enter image description here][2]ve"><span>1</span></li><li><a href="http://localhost:3000/paketsoal/public/dashboard/my-product/?page=2">2</a></li> <li><a href="http://localhost:3000/paketsoal/public/dashboard/my-product/?page=2" rel="next">?</a></li></ul>

enter image description here

在此处输入图片说明

回答by Limon Monte

You should use unescaped block {!! !!}:

您应该使用未转义的块{!! !!}

{!! $products->render() !!}