how to use underscore.js library in angular 2

前端 未结 6 1241
夕颜
夕颜 2020-12-29 20:47

I trying to create an application with angular 2,and want use underscore.js library in my .ts files ,for example when i want use this function :

   let myId         


        
6条回答
  •  星月不相逢
    2020-12-29 21:14

    You have to Add TypeScript Definitions for Underscore:

    tsd install underscore

    Configure SystemJS

    System.config({
      [...]
      paths: {
        underscore: './node_modules/underscore/underscore.js'
      }
    });
    

    Finally import the Module

    import * as _ from 'underscore';
    

提交回复
热议问题