duanhuang1699 2015-07-30 14:17
浏览 162
已采纳

Laravel 5:添加自定义样式/脚本

This is kind of a stupid question, and I've looked around for similar answers and found some, however they are a bit more specific than what I am asking.

Say I want to include a custom styles.css or scripts.js file, would I just create a css/js folder in resources/views folder, and then call to them in my blade.php files like I would normally do in an HTML file when not using Laravel?

Example: <link type="text/css" rel="stylesheet" href="css/styles.css">

Or is there a different approach to this in Laravel?

  • 写回答

2条回答 默认 最新

  • dsg56465 2015-07-30 14:31
    关注

    Put your css files into the public folder like public/css/styles.css

    Use the asset() function to add css, javascript or images into your blade template.

    For Style Sheets

    <link href="{{ asset('css/styles.css') }}" rel="stylesheet" type="text/css" >
    

    or

    <link href="{{ URL::asset('css/styles.css') }}" rel="stylesheet" type="text/css" >
    

    For Javascript

    <script type="text/javascript" src="{{ asset('js/scripts.js') }}"></script>
    

    or

     <script type="text/javascript" src="{{ URL::asset('js/scripts.js') }}"></script>
    

    You may also be interested to have a look at Laravel's Elixir to process your styles and javascript.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 Fluent齿轮搅油
  • ¥15 八爪鱼爬数据为什么自己停了
  • ¥15 交替优化波束形成和ris反射角使保密速率最大化
  • ¥15 树莓派与pix飞控通信
  • ¥15 自动转发微信群信息到另外一个微信群
  • ¥15 outlook无法配置成功
  • ¥30 这是哪个作者做的宝宝起名网站
  • ¥60 版本过低apk如何修改可以兼容新的安卓系统
  • ¥25 由IPR导致的DRIVER_POWER_STATE_FAILURE蓝屏
  • ¥50 有数据,怎么建立模型求影响全要素生产率的因素