简体   繁体   English

jQuery在Angular 5中不起作用

[英]Jquery not working in Angular 5

I tried to use Jquery in Angular5 it works on one my components but not in inner components 我试图在Angular5中使用Jquery只能在我的一个组件上使用,而不能在内部组件上使用

I have imported it in app.component.ts: 我已将其导入app.component.ts中:

import { Component } from '@angular/core'; import * as $ from 'jquery';

It works inside the header section: app/layout/components/header. 它在标题部分内工作: app/layout/components/header.

But not into the inner components which like this: app/layout/stores/store/store-info 但不要进入像这样的内部组件: app/layout/stores/store/store-info

Tried to import jquery in all the modules still not working 试图在所有模块中导入jquery仍然无法正常工作

Help Appreciated 帮助表示赞赏

@Melchia, Thanks I have already imported jquery and its working. @Melchia,谢谢,我已经导入了jquery及其工作。 It was only nor working in some of the components. 它只是在某些组件中也不起作用。

I tried this: 我尝试了这个:

$(document).on({

// functionality

})

And it works now! 现在就可以了!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM