gpt4 book ai didi

javascript - Angular2从query.selectareas.js导入自调用的jQuery库给出运行时错误: jQuery is not defined

转载 作者:行者123 更新时间:2023-12-03 03:22:10 24 4
gpt4 key购买 nike

我在这里遇到了奇怪的问题,自调用函数需要jquery

这是我想使用的库:jquery.selectareas.js

这是代码

import * as jQuery from 'jquery';
import "query.selectareas.js"

Runtime Error : jQuery is not defined at this line

我尝试使用所有不同的组合导入 JQ

//import * as $ from 'jquery';
//import * as jQuery from 'jquery';
//window['$'] = window['jQuery'] = $;
//import "jquery"

据我所知,导入的 jQuery 应该在 jquery.selectareas.js 内可用导入时的范围,因为它们将在同一范围内。

注意:jquery工作我在所有导入语句之后使用了它

最佳答案

您可能需要imports-loader

import  "imports-loader?jQuery=jquery!query.selectareas.js"

这会将 jQuery 变量注入(inject)到您导入的模块中

关于javascript - Angular2从query.selectareas.js导入自调用的jQuery库给出运行时错误: jQuery is not defined,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46521438/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com