rsmalc/laravel-noty

使用 Noty v3 库为 Laravel 应用提供闪存消息

2.6.0 2023-10-25 21:40 UTC

This package is not auto-updated.

Last update: 2024-09-25 00:37:18 UTC


README

这是我的第一个 Laravel 扩展包,我受到了 Jeffrey Way - Easy Flash Messages 的启发

安装

包安装

使用 composer 安装包。

运行 composer require rsmalc/laravel-noty

在 Laravel 5 中,将服务提供者在 config/app.php 中包含。

'providers' => [
    RSmalc\Noty\NotyServiceProvider::class,
];

Noty 库安装

通过 Bower 安装

$ bower install noty

通过 NPM 或 YARN 安装

$ npm install noty
$ yarn add noty

通过 Composer 安装

$ composer require needim/noty

使用 gulp 或 webpack 编译它,或者直接将所有文件复制到 public 文件夹。

使用

<head>    
    <link rel="stylesheet" href="/noty.css"></script>
    <script type="text/javascript" src="/noty.js"></script>
</head>

在布局视图中添加

@include('noty::message')

在项目中使用

noty('Your message');

您也可以选择消息类型(警告、成功、错误、警告、信息)

noty('Your message', 'alert'); // default 
noty('Your message', 'success');
noty('Your message', 'error');
noty('Your message', 'warning');
noty('Your message', 'information');

配置

您可以为通知消息设置全局配置。

php artisan vendor:publish   

将在 config/laravel-noty.php 文件夹中创建一个文件

许可证

MIT 许可证 (MIT)。有关更多信息,请参阅 许可证文件