【问题标题】:html class not found in laravel template在 laravel 模板中找不到 html 类
【发布时间】:2016-10-06 08:09:33
【问题描述】:

这是我的 main.blade.php 文件

    <head>
        <title>App Name - @yield('title')</title>
        <!-- Latest compiled and minified CSS -->
        <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" integrity="sha384-1q8mTJOASx8j1Au+a5WDVnPi2lkFfwwEAa8hDDdjZlpLegxhjVME1fgjWPGmkzs7" crossorigin="anonymous">

        <!-- Optional theme -->
        <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap-theme.min.css" integrity="sha384-fLW2N01lMqjakBkx3l/M9EahuwpSfeNvV63J5ezn3uZzapT0u7EYsXMjQV+0En5r" crossorigin="anonymous">

        <!-- Latest compiled and minified JavaScript -->

    </head>
    <body>
        <div class="container">
            @yield('content')
        </div>


        <script
              src="https://code.jquery.com/jquery-2.2.4.min.js"
              integrity="sha256-BbhdlvQf/xTY9gja0Dq3HiwQF8LaCRTXxZKRutelT44="
              crossorigin="anonymous"></script>
         <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js" integrity="sha384-0mSbJDEHialfmuBBQP6A4Qrprq5OVfW37PRR3j5ELqxss1yVqOtnepnHVP9aJ7xS" crossorigin="anonymous"></script>
         {{ HTML::script('js/funciones.js') }}//the html class is not found
    </body>
</html>

当我尝试在服务器上执行文件时出现此错误

FatalErrorException in a17fd89ebbf444a204167f09a50ec2b0fd529cbe.php line 24: Class 'HTML' not found

但是我已经按照说明添加了 laravell 集体库,在这个 url https://laravelcollective.com/docs/5.2/html 上,一切似乎都是正确的

【问题讨论】:

    标签: php html laravel laravel-blade laravelcollective


    【解决方案1】:

    {{ HTML::script('js/funciones.js') }} 替换为{!! HTML::script('js/funciones.js') !!} 就可以了。有关{{ }}{!! !!} 之间的区别的更多信息,请查看this

    希望对你有帮助:)

    【讨论】:

    • 你的 app.php 中有'Html' =&gt; Illuminate\Html\HtmlFacade::class
    • 'Html' =&gt; Collective\Html\HtmlFacade::class 在别名数组上
    • 你也有提供者?
    • Collective\Html\HtmlServiceProvider::class 在提供者数组上
    • 'Html' =&gt; Collective\Html\HtmlFacade::class 改成大写别名HTML
    猜你喜欢
    • 2016-07-09
    • 2016-11-16
    • 2019-07-04
    • 2016-02-17
    • 2015-07-17
    • 2017-03-05
    • 2016-03-22
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多