【问题标题】:Blade view not rendering in laravel刀片视图未在 laravel 中渲染
【发布时间】:2017-02-07 22:15:34
【问题描述】:

我正在开发一个网站,必须完成候选人输入和记录搜索。

我创建了一个 Blade 视图文件。其中有根据if条件调用的不同部分。

我的 Display.blade.php 视图如下

<center>
    @if($ID>0)
        <table border="0" width="100%">
            <tr>
                <td>@include('Header')</td>
            </tr>
            <tr>
                <td style="font-family:arial;font-size:30px;text-align:center;">Edit Registration</td>
            </tr>
        </table>
    @endif

<!--First Call-->
@if($ID < 0)
    <table border="0" width="100%">
        <tr>
            <td>@include('Header')</td>
        </tr>
        <tr>
            <td style="font-family:arial;font-size:30px;text-align:center;">New Registration1</td>
        </tr>
    </table>
    <form action="/Register" method="post" target="_self">
    <input type = "hidden" name = "_token" value = "<?php echo csrf_token() ?>">    
        <table border="1" width="70%" cellpadding="3" style="border-collapse: collapse" bordercolor="#eeeeee">
            <tr>
                <td>First Name</br><input type="text" name="fname" /></td>

                <td>Middle Name</br><input type="text" name="mname" /></td>

                <td>Last Name</br><input type="text" name="lname" /></td>
                <td>Contact No</br><input type="text" name="contactno" /></td>
            </tr>
            <tr>
                <td colspan="4" align="center"><input type="submit" value="Submit"></td>
            </tr>
        </table>
    </form>
@endif
</center>

Header.blade.php 如下。

    <style>
        .container 
        {
             background-image: url("header.jpg");
              background-repeat: repeat-all;
             left:0;
             top:0;
             width:100%;
             height:80px;
        }
 </style>

        <div class="container">
            <div class="Cname">Cube Placement</div>
            <div class="rTable">
                <div class="rTableRow">
                    <div class="rTableHead">
             <strong>
              <a href='{!!url('/Register'); !!}'>Register</a>
             </strong></div>
                    <div class="rTableHead"><strong>Report</strong></div>
                </div>
            </div>
        </div>

代码执行良好。执行编辑注册部分时,页面中缺少 CSS,但当调用新注册部分时,CSS 工作正常。 除了一切正常。

我的代码有什么问题。

【问题讨论】:

  • 如何在刀片文件中包含 css?
  • 我在 display.blade 和 header.blade 的样式部分都包含了 CSS。就像在一个 if 条件 css 样式确实出现但不在另一个中一样
  • 您说页面中缺少 css。那么“如何”将其插入两个文件中?根据您插入资产的方式,它可能会或可能无法从特定位置访问
  • 我可能解释不正确,对此我深表歉意。我通过 css 在 Header.blade.php 文件中包含了一个 header.jpg 图像。但是header.jpg文件不包含在编辑注册中
  • 你能在你添加css的地方添加代码吗?

标签: php css laravel


【解决方案1】:

要使您的 css 在每个页面上都可以访问,请将 css 文件放在 public 文件夹中的文件夹中,并在调用 css 文件的链接标记中使用此代码,最好是在每个页面上加载的文件中。

{{ URL::to('/') }}/path/style.css

这里你对浏览器说去 yourdomain.com/path/style.css

希望对你有用

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2018-10-03
    • 1970-01-01
    • 2023-04-08
    • 1970-01-01
    • 2022-07-20
    • 1970-01-01
    • 2016-04-04
    • 2020-09-13
    相关资源
    最近更新 更多