jquery - Laravel 5.8 require 函数在 app.js 中找不到

标签 jquery laravel charts

我正在尝试在 Laravel 前端应用程序中添加图表。

  1. 在 app.js 中我添加了 require('./horizBarChart');
  2. 在 app.scss 中我添加了 @import 'horizBarChart.scss';
  3. 在 app.js 之后,我添加了函数调用方法(以及有效的 jQuery 测试): enter image description here

现在,编译后我看到 horizBarChart 函数包含在我的 app.js 生成的文件中: enter image description here

但是打开网站时我仍然收到功能未找到错误: enter image description here

如果我不使用 require 但将其包含为基本 <script src="../jquery.horizBarChart.min.js"></script>一切正常。

我在这里做错了什么?

最佳答案

HTML中的

link标签用于css,对于scripts它应该是:

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

而且我认为您应该将此行放在 jQuery 下方,而不是上方,因为我看到该库也使用 jQuery,因此请确保首先加载 jQuery。

关于jquery - Laravel 5.8 require 函数在 app.js 中找不到,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57289880/

相关文章:

php - 如何在不使用 ajax 刷新页面的情况下向现有对话添加新行?

php - Laravel、Guzzle 和 Salesforce - 不支持的资助类型

php - Laravel 命令-> 选择循环

javascript - 如何获取我的 Google 图表的 png 图像链接

Angular Primeng : ERROR ReferenceError: Chart is not defined at UIChart. initChart (chart.js:53)

php - 通过php脚本异步下载文件

javascript - 如何使用 Ajax 和 JSON 获取天气信息并将其放入 HTML 段落中?

jquery - 使用 jQuery 从 href 获取值

laravel - 如果 worker 数量 > 1,Heroku worker 会在 laravel 应用程序中崩溃

javascript - 在 mouseenter generateLegend Chartjs 2 上突出显示 donut 段