javascript - 为什么其他 JavaScript 文件在我的 PHP 文件中不起作用?
问题描述
单击以查看我使用 Laravel(最新版本)和 Vue 2 的图像。当我在 file.blade.php 页面中包含默认的 app.js(唯一有效的 js 文件)时,它可以工作。但是,如果我在与 app.js (ressource/js/app.js) 相同的路径中创建另一个 js 文件示例:apple.js,它不想找到它。
控制台谷歌浏览器:GET http://127.0.0.1:8000/js/apple.js net::ERR_ABORTED 404(未找到)
我已经尝试过的:
script src="{{URL::asset('/js/apple.js')}}" /script
和
script src="{{asset('/js/apple.js')}}" /script
和
script src="/js/apple.js" /script
最后
script src="js/apple.js" /script
我出于展示目的而取消报价。
<!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>
解决方案
大多数情况下,由于我们忘记编译文件而发生这种情况。确保您编译了该文件,并且它出现在公用文件夹中。
对于编译,运行命令:
npm run dev
对于持续编译,运行watch
命令:
npm run watch
推荐阅读
- python-3.x - 如果满足条件,如何比较字典中的两个值并返回第三个值?
- flutter - Flutter:如何知道列表视图中的项目位置?
- python - 如何使用 Flask 展示特定文件中的所有图像?
- python - 何将列表附加到数据框?
- python - .findall(文本)上的语法无效,仅突出显示 ( 或随机字母?
- sql - Oracle XMLTABLE,具有属性的根
- elasticsearch - ElasticSearch _count 和 _search 应用相同的查询
- php - imagefttext() 函数 (php) 增加图像的大小
- ssas - 如何在 MDX 中使用中值函数?
- laravel - 不能使用 hasOne 关系来放置限制