jquery - 如何将jquery添加到茉莉花
问题描述
我收到以下错误:
ReferenceError: $ is not defined
error properties: Object({ ngDebugContext: DebugContext_({ view: Object({ def: Object({ factory: Function, nodeFlags: 33669121, rootNodeFlags: 33554433, nodeMatchedQueries: 0, flags: 0, nodes: [ Object({ nodeIndex: 0, parent: null, renderParent: null, bindingIndex: 0, outputIndex: 0, checkIndex: 0, flags: 33554433, childFlags: 114688, directChildFlags: 114688, childMatchedQueries: 0, matchedQueries: Object({ }), matchedQueryIds: 0, references: Object({ }), ngContentIndex: null, childCount: 1, bindings: [ ], bindingFlags: 0, outputs: [ ], element: Object({ ns: '', name: 'app-asignacion', attrs: [ ], template: null, componentProvider: Object({ nodeIndex: 1, parent: <circular reference: Object>, renderParent: <circular reference: Object>, bindingIndex: 0, outputIndex: 0, checkIndex: 1, flags: 114688, childFlags: 0, directChildFlags: 0, childMatchedQueries: 0, matchedQueries: Object, matchedQueryIds: 0, references: Object, ngContentIndex: -1, childCount: 0, bindings: Array, bindingFlags: 0, outputs: ...
at <Jasmine>
at AsignacionComponent.ngOnInit (http://localhost:9876/_karma_webpack_/main.js:6206:5)
at checkAndUpdateDirectiveInline (http://localhost:9876/_karma_webpack_/node_modules/@angular/core/fesm2015/core.js:31910:1)
at checkAndUpdateNodeInline (http://localhost:9876/_karma_webpack_/node_modules/@angular/core/fesm2015/core.js:44367:1)
at checkAndUpdateNode (http://localhost:9876/_karma_webpack_/node_modules/@angular/core/fesm2015/core.js:44306:1)
at debugCheckAndUpdateNode (http://localhost:9876/_karma_webpack_/node_modules/@angular/core/fesm2015/core.js:45328:36)
at debugCheckDirectivesFn (http://localhost:9876/_karma_webpack_/node_modules/@angular/core/fesm2015/core.js:45271:1)
at Object.eval [as updateDirectives] (ng:///DynamicTestModule/AsignacionComponent_Host.ngfactory.js:10:5)
at Object.debugUpdateDirectives [as updateDirectives] (http://localhost:9876/_karma_webpack_/node_modules/@angular/core/fesm2015/core.js:45259:1)
at checkAndUpdateView (http://localhost:9876/_karma_webpack_/node_modules/@angular/core/fesm2015/core.js:44271:1)
at callWithDebugContext (http://localhost:9876/_karma_webpack_/node_modules/@angular/core/fesm2015/core.js:45632:1)
我尝试在 karma.conf.js 中添加 jquery 的路径,但问题仍然存在
module.exports = function(config) {
config.set({
files: [
'node_modules/jquery/jquery.min.js',
],
//rest karma options
});
};
来人帮帮我?
谢谢你!!!
解决方案
对于那些将来遇到同样问题并获得与我在这篇文章中获得的相同帮助的人。
只需添加 karma.conf.js
files:[
"node_modules/jquery/dist/jquery.min.js",
"node_modules/popper.js/dist/umd/popper.min.js",
"node_modules/bootstrap/dist/js/bootstrap.min.js"
]
推荐阅读
- flutter - 是否有类似于 CombineLatest 仅适用于 1 个流的功能?
- visual-studio-2010 - “HtmlAgilityPack”已经为“System.Net.Http”定义了一个依赖项
- java - 在 Wicket 7 中打开多个选项卡时,文件上传上的“无法从字节 [] 反序列化对象”
- python - 使用矢量化函数重新分类 numpy 浮点数组时出现广播错误
- c# - 施放 SynchronizedCollection
只读 SynchronizedReadOnlyCollection - swift - 向后传递数据时,在展开可选值时意外发现 nil
- node.js - 检测到套接字 io 可能的 EventEmitter 内存泄漏
- angular - 即使测试通过,组件中的 Angular setTimeout() 调用也会导致测试中出现控制台错误
- angular - 如何知道点击了哪个特定的 toastr?
- javascript - Oracle Apex 交互式报表在恢复滚动位置后不刷新