2017-04-20 10:00
浏览 98


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?

图片转代码服务由CSDN问答提供 功能建议

我在 / public / js / 中有一个名为 myjavascript的javascript文件。 js



&lt; script src =“/ js / myjavascript.js”&gt;&lt; / script&gt; 
 @ section('content')

此工作在其他项目中,但不在此新项目中。 我做错了什么?

  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

4条回答 默认 最新

  • dongzhenyin2001 2017-04-20 10:05

    Try like this

    <script src="{{ asset('/js/myjavascript.js') }}"></script>
    打赏 评论
  • duancha1065 2017-04-20 10:04

    Try this:

    <script rel="text/javascript" src="{{ URL::asset('js/myjavascript.js') }}"></script>
    打赏 评论
  • donglao4370 2017-04-20 10:10

    I think your code need to update like:

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

    Hope this work for you!

    打赏 评论
  • dongzhuo8210 2017-04-20 12:52

    <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

    打赏 评论

相关推荐 更多相似问题