문제

Wondering how can I link with blade syntax to my jquery/javascript files?

 <script src="../../public/js/jquery.min.js"></script>


 <script src="../../public/js/bootstrap.js"></script>

This didn't work:

 <link type="text/css" rel="stylesheet" href="{{ URL::to('js/jquery.min.js') }}"> 

 <link type="text/css" rel="stylesheet" href="{{ URL::to('js/bootstrap.js') }}">
도움이 되었습니까?

해결책

URL::to($param) directs to your root folder (/public) and adds the string folders. URL::to('js/bootstrap.js') directs to /public/js/bootstrap.js. this looks correct to me.

although you used a css linking tag for javascript. try using:

<script src="{{ URL::to('js/jquery.min.js') }}"></script>
<script src="{{ URL::to('js/bootstrap.js') }}"></script>

다른 팁

You should use the following:

<script src="{{ URL::asset('/js/jquery.min.js') }}"><script/>
<script src="{{ URL::asset('/js/bootstrap.js') }}"><script/>

This will always work. If you are creating a package in workbench this is also the way to go.

And if you want to publish your assets to public you will do:

php artisan asset:publish --bench="vendor/package"
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top