dongsun2789 2018-12-13 13:12 采纳率: 100%
浏览 75

未定义的变量:在laravel中使用bootstrap组件时出现类错误

We are trying use bootstrap components for our fresh laravel project.

GitHub: https://github.com/appstract/laravel-bootstrap-components

we have following code in blade. but it doesn't work and have error.

blade codes:

@extends('layouts.app')
@section('page-title','Welcome')

@section('content')
    @component('bootstrap::alert', ['type' => 'danger'])
        A simple alert of danger type
    @endcomponent
@stop

error:

ErrorException (E_ERROR) Undefined variable: class (View: B:\xampp\htdocs\me2weesources\views\vendor\bootstrap\alert.blade.php) (View: B:\xampp\htdocs\me2weesources\views\vendor\bootstrap\alert.blade.php)

what we have to do to fix it?

  • 写回答

1条回答 默认 最新

  • douzhankui0758 2018-12-13 13:31
    关注

    It seems alert.blade.php contains the following snippet:

    {{ $class or '' }}
    

    The latest version of Laravel no longer supports or between curly brackets in blade. These have been replaced by PHP 7's null coalesce operator.

    So it should now be like this:

    {{ $class ?? '' }}
    

    More info: https://laravel-news.com/blade-templates-null-coalesce-operator

    评论

报告相同问题?

悬赏问题

  • ¥15 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?
  • ¥15 c++头文件不能识别CDialog