lucasruroken/laravel-font-awesome

此包最新版本(v1.0.0)没有可用的许可证信息。

用于构建 FontAwesome 图标的辅助类

v1.0.0 2016-09-02 12:53 UTC

This package is not auto-updated.

Last update: 2024-09-23 14:02:48 UTC


README

辅助类,用于使用预定义的标记创建 FontAwesome 图标。基于 Digbang\FontAwesome

此包允许你在 Laravel 应用程序中创建门面。但如果你愿意,也可以在没有 Laravel 的情况下使用此包。

使用方法

基本使用

$fa = new FontAwesome();
$fa->icon('icon', ['class' => 'extra-class'])

基本使用 Laravel 5.*

FontAwesome::icon('icon', ['class' => 'extra-class'])

将得到...

<i class="fa fa-icon extra-class"></i>

HTML 属性

你还可以向 HTML 添加其他任何属性。执行...

$fa->icon('times', ['title' => 'Delete this!'])

将得到...

<i class="fa fa-times" title="Delete this!"></i>

更改标签

你可以更改库使用的标签。执行...

$fa->setTag('span');
$fa->icon('edit');

将得到...

<span class="fa fa-edit"></span>

Laravel

将服务提供者和门面添加到你的 config/app.php 文件中

'providers' => array(
	...
	'LucasRuroken\FontAwesome\FontAwesomeServiceProvider',
	...
);

并添加类别名,这样你就可以像 \FontAwesome::icon 一样调用它

'aliases' => array(
	...
	'FontAwesome' => 'LucasRuroken\FontAwesome\Facade',
	...
);