2017-04-20 10:00


I have a javascript file in /public/js/ called myjavascript.js .

I want to include it in my site.

So I did this:


        <script src="/js/myjavascript.js"></script>


This work in other project but not in this new one. What am I doing wrong?

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享
  • 邀请回答


  • dongzhenyin2001 dongzhenyin2001 4年前

    Try like this

    <script src="{{ asset('/js/myjavascript.js') }}"></script>
    点赞 评论 复制链接分享
  • dongzhuo8210 dongzhuo8210 4年前

    <script src="{{ asset('/js/myjavascript.js') }}"></script> is perfect.

    Check your APP_URL from .env file.

    if your then your source will be

    if your then your source will be
    Check '' for more about asset helper function

    点赞 评论 复制链接分享
  • donglao4370 donglao4370 4年前

    I think your code need to update like:

    {!! Html::script('js/myjavascript.js') !!}

    Hope this work for you!

    点赞 评论 复制链接分享
  • duancha1065 duancha1065 4年前

    Try this:

    <script rel="text/javascript" src="{{ URL::asset('js/myjavascript.js') }}"></script>
    点赞 评论 复制链接分享