coderello / laravel-shared-data
用于在 Laravel 和 JavaScript 之间共享数据的包。
4.0.0
2022-02-22 14:31 UTC
Requires
- php: ^8.0
- ext-json: *
- illuminate/support: ^9.0
Requires (Dev)
- orchestra/testbench: ^7.0
- 4.0.x-dev
- 4.0.0
- 3.2.0
- 3.1.1
- 3.1.0
- 3.0.x-dev
- 3.0.0
- 2.1.0
- 2.0.x-dev
- 2.0.0
- 1.4.0
- 1.3.0
- 1.2.0
- 1.1.0
- 1.0.x-dev
- 1.0.0
- 0.2.0
- 0.1.0
- dev-hivokas-patch-1
- dev-shared-helper-function
- dev-master
- dev-directive
- dev-deep-data-conversion
- dev-deep-data-convertion
- dev-key-transformer
- dev-delayed-closures
- dev-travisci-test
This package is auto-updated.
Last update: 2024-09-22 20:08:18 UTC
README
✨ 介绍
laravel-shared-data 提供了一种简单的方法,将后端数据共享到 JavaScript。
🚀 快速开始
-
安装包
composer require coderello/laravel-shared-data
-
在所有脚本之前将
@shared
指令包含到你的 blade 布局中。 -
在 Laravel 中共享数据
share(['user' => $user, 'title' => $title]);
-
直接从 JavaScript 访问数据
const user = window.sharedData.user; const title = window.sharedData.title;
-
或使用内置的全局助手
const user = shared('user'); const title = shared('title');
📖 许可证
laravel-shared-data 是开源软件,许可协议为 MIT 许可证。