【问题标题】:Laravel blade view page is empty even though there is source codeLaravel 刀片视图页面是空的,即使有源代码
【发布时间】:2017-02-15 13:48:59
【问题描述】:

我的刀片视图显示一个空白页面,但如果我按 CTRL + U 显示源代码,那么我会得到:

<!DOCTYPE html>
<html>
<head>
    <link rel='stylesheet' href='http://localhost/portal_testing/public/css/style.css'/>
    <script src='http://localhost/portal_testing/public/js/main.js'/>
</head>
<body>
    <div>   
        <div class='infoBox'>
            <h4 class='infoBoxTitle'>Log:</h4>
            <div class='infoBoxContent'> 
               <p>test</p>
            </div>
        </div>

        <div class='errorBox'>
            <h4 class='errorBoxTitle'>Error Log:</h4>
            <div class='errorBoxContent'> 
               <p>test</p>
            </div>
        </div>
    </div>
</body>
</html>

为什么有有效代码却不渲染?

更新:


Javascript:

//Accordion:
var acc = document.getElementsByClassName("accordion");
var i;

for (i = 0; i < acc.length; i++) {
    acc[i].onclick = function(){
        this.classList.toggle("active");
        var panel = this.nextElementSibling;
        if (panel.style.display === "block") {
            panel.style.display = "none";
        } else {
            panel.style.display = "block";
        }
    }
}

CSS

.infoBox {
    font-family: arial;
    padding:2px;
    background-color: #DADADA;
    min-width: 300px;
    min-height: 100px;
    margin:2px;
    border:1px solid black;
}

.infoBoxTitle {
    padding:4px;
    font-size: 13px;
    color: red;
    margin: 1px;
    text-decoration: underline;

}

.infoBoxContent {
    font-size: 10px;
    padding-left:5px;
    margin-left:10px;
    border: 1px solid gray;
}

.errorBox {
    font-family: arial;
    padding:2px;
    background-color: #838383;
    min-width: 300px;
    min-height: 100px;
    margin:2px;
    border:1px solid black;
}

.errorBoxTitle {
    padding:4px;
    font-family: calibry;
    font-size: 13px;
    color: white;
    margin: 1px;
    text-decoration: underline;
}

.errorBoxContent {
    color: white;
    font-size: 11px;
    padding-left:5px;
    margin-left:10px;
    border: 4px solid white;
}

【问题讨论】:

  • 确保没有致命错误,并且没有使用某些 CSS 隐藏内容
  • 请显示您的 CSS 和 JS 文件的内容,他们可能负责隐藏元素。
  • 我如何知道是否有致命错误?通过查看 apache 日志?
  • 是的,apache 错误日志
  • 注释掉那个javascript代码,看看它是否能正常工作

标签: php laravel laravel-5.3 blade


【解决方案1】:

我发现了问题... 我注意到所有内容都呈现在脚本标签内:

原因是,脚本元素缺少结束标记。


修复:

<script type="text/javascript" src='{{ URL::asset("js/main.js") }}'></script>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2014-08-14
    • 1970-01-01
    • 2015-08-20
    • 2020-05-27
    • 2013-08-03
    • 2020-08-09
    • 2016-09-09
    • 1970-01-01
    相关资源
    最近更新 更多