sukohi/laravel-js-helper
Composer 安装命令:
composer require sukohi/laravel-js-helper
包简介
A Laravel package that provides helper functions for JavaScript like route(), dd() and constant().
关键字:
README 文档
README
A Laravel package that provides helper functions for JavaScript like route(), dd() and constant().
Available versions:
- Laravel 9
- Laravel 8
- Laravel 7
- Laravel 6
Installation
Run the following command to install the package:
composer require sukohi/laravel-js-helper
Then, publish a config file called config/js_helper.php.
php artisan vendor:publish --tag="laravel-js-helper-config"
After that, set your route names and/or constants that you'd like to use in JavaScript in the file`.
Usage
<script src="/js/helper.js"></script>
<script>
window.onload = () => {
// URL from routes
const url = route('item.edit', 1); // <- here
console.log(url);
// Constants
const appName = constant('APP_NAME'); // <- here
console.log(appName);
// Debug
const str1 = 'Test 1';
const str2 = 'Test 2';
const str3 = 'Test 3';
dd(str1, str2, str3); // <- here
};
</script>
License
This package is licensed under the MIT License.
统计信息
- 总下载量: 7
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 1
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2022-02-15