How to use jQuery with javascript in angular 2

前端 未结 7 883
说谎
说谎 2020-12-05 01:13
    import {Component, ElementRef, OnInit} from \'angular2/core\';
    declare var jQuery:any;
    @Component({
      selector: \'jquery-integration\',
      templat         


        
7条回答
  •  伪装坚强ぢ
    2020-12-05 01:54

    we can use like as follow:

    var jq=require('./jquery.min.js');
    .....
    export class AppComponent{
      ngOnInit(){
       jq();
       console.log($('body'))  // show:[body, prevObject: r.fn.init[1]]
                               //ok!normal operation!
      }
    }
    

提交回复
热议问题