jquery - 如何在编译的 npm webpack 文件中使用 jquery 函数而不将 jquery 导入编译输出
问题描述
我正在使用 bootstrap 4,并且正在将 bootstrap 编译为最终theme.js
输出文件,以整合我所有的自定义 js 和其他节点供应商。
但我想通过这样的 CDN 将我的 jQuery 单独加载到标题中......
<!DOCTYPE html>
<html>
<head>
<script src="https://code.jquery.com/jquery-3.3.1.min.js"></script>
</head>
<body>
<script src="../dist/js/theme.js"></script>
</body>
</html>
所以我然后像这样处理我的进口theme.js
......
require('bootstrap');
require('popper.js');
require('bootstrap-select');
require('slick-carousel');
require('scrollreveal');
require('lightgallery');
// document ready
(function ($) {
// automatically show the popup
$('#welcomePopup').modal('show');
})(jQuery);
这编译得很好,没有错误。但是在我的网站上运行时,我在控制台中收到此错误theme.js
...
我真的不想将 jQuery 编译到我的theme.js
. 有解决方案吗?
我试过使用jquery-bridget但这没有用。无论如何,我认为这不是正确的工具。我真的可以使用一些友好的建议谢谢。
解决方案
推荐阅读
- generics - Dart 2.7 通用扩展
- javascript - 如何在鼠标悬停时为页面上的所有 div 添加悬停效果?
- mysql - 如何每天将数据从 Cloud SQL 导出到 BigQuery?
- rest - 当正文数据与数据库中的当前状态相同时,使用哪个 REST HTTP 状态码?
- python - 视觉工作室代码远程ssh无法调试python
- arduino - PN532 V3 + Arduino UNO + libnfc 错误(错误:无法打开 NFC 设备:pn532_uart:/dev/ttyUSB0:115200)
- ruby-on-rails - Rails webpacker 无法从 nvm 找到节点版本
- substrate - 如何使用 RPC 调用从 Substrate 读取哈希值并获取相应的 AccountId?
- javascript - JS 问题然后创建一个计算器并能够输入多个数字
- view - SwiftUI 将参数传递给 View 并不总是可用