whossun/laravel-toastr

laravel 5.2 的 toastr.js

1.0.1 2016-07-10 11:12 UTC

This package is not auto-updated.

Last update: 2024-09-23 13:47:18 UTC


README

安装

使用 Composer

composer require whossun/laravel-toastr

将服务提供者添加到 config/app.php

Whossun\Toastr\ToastrServiceProvider::class,

如果需要,可以可选地将 Facade 包含在 config/app.php 中。

'Toastr'  => Whossun\Toastr\Facades\Toastr::class,

选项

您可以为 Reminder 设置自定义选项。运行

php artisan vendor:publish

以发布 toastr 的配置文件。

您可以通过 toastr 的文档 来自定义您的需求。

您可以使用可用的 toastr() 函数。

依赖关系

jQuery toast,您需要将 css 和 js 添加到您的 HTML 中。

基本

  • Toastr::info('message', 'title', ['options']);

  • Toastr::success('message', 'title', ['options']);

  • Toastr::warning('message', 'title', ['options']);

  • Toastr::error('message', 'title', ['options']);

  • Toastr::clear();

  • Toastr()->info('message', 'title', ['options']);

<?php

Route::get('/', function () {
    Toastr::success('Messages in here', 'Title', ["positionClass" => "toast-top-center"]);

    return view('welcome');
});

然后

您应该在您的 HTML 中添加 {!! Toastr::message() !!}

<!DOCTYPE html>
<html>
    <head>
        <title>Laravel</title>
        <link rel="stylesheet" href="http://cdn.bootcss.com/toastr.js/latest/css/toastr.min.css">
    </head>
    <body>
        <div class="container">
            <div class="content">
                <div class="title">Laravel 5</div>
            </div>
        </div>
		<script src="http://cdn.bootcss.com/jquery/2.2.4/jquery.min.js"></script>
        <script src="http://cdn.bootcss.com/toastr.js/latest/js/toastr.min.js"></script>
        {!! Toastr::message() !!}
    </body>
</html>

MIT