Click to see the image I work with Laravel(last version) and Vue 2. When I include default app.js (the only js files that work) in my file.blade.php page it work. But if I create a other js file example: apple.js in the same path than app.js (ressource/js/app.js),it doesn't want to find it.
Console google chrome : GET http://127.0.0.1:8000/js/apple.js net::ERR_ABORTED 404 (Not Found)
What I have already tried:
script src="{{URL::asset('/js/apple.js')}}" /script
AND
script src="{{asset('/js/apple.js')}}" /script
AND
script src="/js/apple.js" /script
AND FINALLY
script src="js/apple.js" /script
I take off quote for display purpose.
<!DOCTYPE html>
<html>
<head>
<title></title>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bulma/0.7.2/css/bulma.css">
<meta name="csrf-token" content="{{ csrf_token() }}">
<style>
body { padding-top:40px; }
</style>
</head>
<body>
<div id="something" class="container">
<tabs>
<tab name="About us" :selected="true">
<h1>Here is the content for theabout us tab</h1>
</tab>
<tab name="About our Culture">
<h1>Here is the content for the about our culture tab</h1>
</tab>
<tab name="About Our Vision">
<h1>Here is the content for the about our vision tab</h1>
</tab>
</tabs>
</div>
<script src="{{asset('/js/apple.js')}}"></script>
</body>
</html>
Most of the time it happens due to we forget to compile the file. Make sure you compile the file and it appears in public folder.
For compilation, run command:
npm run dev
For continuous compilation, run watch
command:
npm run watch
Try using this if you are using it in blade file.
@section('script')
<script .....></script>
@endsection
尝试在公共目录而不是资源目录中创建一个文件夹(将其命名为您想要的名称,通常我将其命名为js,因为它包含js文件),而不是在resources目录中,然后使用以下命令调用该文件:
<script type='text/javascript' src="{{ asset('/js/apple.js') }}"></script>
Change directory structure resource/js/apple.js
to public/js/apple.js
<script type="text/javascript" src="{{ URL::asset('js/apple.js') }}"></script>
This will work if your directory structure is like this: /public/js/apple.js
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.