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 文件


基础教程推荐
- PHPUnit 的 Selenium 2 文档到底在哪里? 2022-01-01
- php 7.4 在写入变量中的 Twig 问题 2022-01-01
- 主题化 Drupal 7 的 Ubercart “/cart"页 2021-01-01
- php中的foreach复选框POST 2021-01-01
- php中的PDF导出 2022-01-01
- 将变量从树枝传递给 js 2022-01-01
- 如何在数学上评估像“2-1"这样的字符串?产生“1"? 2022-01-01
- 使用 scandir() 在目录中查找文件夹 (PHP) 2022-01-01
- Yii2 - 在运行时设置邮件传输参数 2022-01-01
- Web 服务器如何处理请求? 2021-01-01