【问题标题】:Edit icon displayed as text编辑图标显示为文本
【发布时间】:2014-06-23 05:35:14
【问题描述】:

我正在 laravel 中创建一个应用程序。我已经创建了一个函数“helper.php”

public static function fa_link_to_action($action, $text, $icon = '', $params = array(), 

    $attrs = array()) {     
                if ($icon) {
                    $text = '<i class="fa fa-' . $icon . '"></i> ' . $text;
                }
                return link_to_action($action, $text, $params, $attrs);        

        }

在我看来,我正在调用这个函数

{{ Helpers\Helper::fa_link_to_action('CarController@edit','Edit','plus',null,$v->id)}}

问题是它显示了这个:&lt;i class="fa fa-plus"&gt;&lt;/i&gt; Edit 不是图标

【问题讨论】:

  • 这是一个 Font-Awesome 类。你的布局中是否正确加载了 Font-Awesome 的 CSS 文件?如果没有这一步,它就不会神奇地工作。
  • 您的图标字符串由link_to_action 助手使用htmlentities 处理,因此您需要对您的助手函数进行一些更改,如以下答案:stackoverflow.com/questions/23322989/…
  • @deczo 说找不到 calss Helper\HTML
  • 如果你在命名空间中有你的助手,那就是\HTML。还要检查@Razor 的答案,因为这似乎是实现相同结果的更快方法。
  • $attributes = \HTML::attributes($attributes); ??

标签: laravel


【解决方案1】:

试试

return \HTML::decode(link_to_action($action, $text, $params, $attrs));

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2021-09-04
    • 1970-01-01
    • 2014-03-20
    • 2016-12-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多