How to include External CSS and JS file in Laravel 5(如何在 Laravel 5 中包含外部 CSS 和 JS 文件)
问题描述
我使用的是 Laravel 5.0,从这个版本中删除了 Form 和 Html Helper,我不知道如何在我的头文件中包含外部 css 和 js 文件.目前我正在使用此代码.
I am Using Laravel 5.0 , the Form and Html Helper are removed from this version , i dont know how to include external css and js files in my header file. Currently i am using this code.
<link rel="stylesheet" href="/css/bootstrap.min.css"> <!--- css file --->
<script type="text/javascript" src="/js/jquery.min.js"></script>
推荐答案
我认为正确的方法是这样的:
I think that the right way is this one:
<script type="text/javascript" src="{{ URL::asset('js/jquery.js') }}"></script>
这里我在 laravel 的 app/public 文件夹中有一个 js 目录.我有一个 jquery.js 文件.函数 URL::asset() 为您生成必要的 url.css 也一样:
Here I have a js directory in the laravel's app/public folder. There I have a jquery.js file. The function URL::asset() produces the necessary url for you. Same for the css:
<link rel="stylesheet" href="{{ URL::asset('css/somestylesheet.css') }}" />
希望这会有所帮助.
请记住旧方法:
{{ Form::script() }}
和
{{ Form::style() }}
已被弃用,不能在 Laravel 5 中使用!
are deprecated and will not work in Laravel 5!
这篇关于如何在 Laravel 5 中包含外部 CSS 和 JS 文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:如何在 Laravel 5 中包含外部 CSS 和 JS 文件
基础教程推荐
- 如何替换eregi() 2022-01-01
- Cron Jobs 调用带有变量的 PHP 脚本 2022-01-01
- 学说 dbal querybuilder 作为准备好的语句 2022-01-01
- YouTube API v3 点赞视频,但计数器不增加 2022-01-01
- 如何在 Laravel 5.3 注册中添加动态下拉列表列? 2021-01-01
- 有什么方法可以用编码 UTF-8 而不是 Unicode 返回 PHP`json_encode`? 2021-01-01
- 在PHP中根据W3C规范Unicode 2022-01-01
- 如何在 Laravel 中使用 React Router? 2022-01-01
- PHP PDO MySQL 查询 LIKE ->多个关键词 2021-01-01
- PHP 类:全局变量作为类中的属性 2021-01-01
