Correct way of importing and using lodash in Angular

前端 未结 5 1778
再見小時候
再見小時候 2020-12-13 17:27

I used to be able to use a lodash method in Angular by an import statement that looked like the following:

import {debounce as _debounce} from \'lodash\';
         


        
5条回答
  •  盖世英雄少女心
    2020-12-13 18:03

    This solved it for me, as written under "updated" by Kuncevič and edited by Roy

    yarn add lodash-es
    yarn add @types/lodash-es --dev
    
    import { debounce as _debounce } from 'lodash';
    

    I had to import the es-modules, else I was given compilation errors - most likely due to my configuration (tsconfig.json).

提交回复
热议问题