【发布时间】:2019-10-09 21:26:01
【问题描述】:
我有一个 Laravel 应用程序,我需要包含我的 npm 包中的所有脚本。从数据表和其他工作,我需要 JQuery 工作。我之前从 CDN 实现了 JQuery,现在想从我的节点包中使用它。
我已经使用 npm 安装了它
npm install jquery
但现在我无法使用它们,并且在 chrome-dev-tool 中它显示 $ 为未定义的符号。
资源文件夹中的 bootstrap.js 文件如下,我的 Laravel mix 构建在运行时成功
npm run dev
window._ = require('lodash');
try {
window.Popper = require('popper.js').default; //dont know working or not
window.$ = window.jQuery = require('jquery'); // Present earlier
require('bootstrap'); // working
require('font-awesome/css/font-awesome.css'); // working
require('datatables.net-bs4'); // not working
window.toastr = require('toastr'); // not working
window.DataTable = require('datatables.net'); // not working as jQuery is not working
} catch (e) {}
window.axios = require('axios'); // present from earlier
... continues
我试过了
include('jquery'),
include('jquery/dist/jquery'),
include('jquery/dist/jquery.js')
但不工作
【问题讨论】:
标签: jquery laravel npm package