使用{{-@foreach($ content as $ v_content)-}}不会获取laravel数据

当我使用

@foreach ($content as $v_content)

它不会在表格中显示数据。 如果不使用endforeach,则数据将显示在表中

我评论foreach代码

当我使用

{{- @foreach ($ content as $ v_content) -}}

表中的数据丢失。

我曾经从数据库中调用数据,但是丢失了

评论
  • 招静娴
    招静娴 回复

    Please write the code so it will be easier for us to see the error and make changes to the code accordingly. We also need to see your controller as well as we need to know what you are trying to display from the table. As you are using, @foreach($ content as $ v_content) make sure to use $v_content to display the required column from the table. For example, if you have item and price in your table content then to display in foreach loop you must use something like this.

    <tr>
    <th> Item </th>
    <th> Price </th>
    </tr> 
    @foreach($content as $v_content)
    <tr>
    <td> {{$v_content->item}} </td>
    <td> {{$v_content->price}} </td>
    </tr>
    @endforeach