How to Import a Single Lodash Function?

后端 未结 7 1799
無奈伤痛
無奈伤痛 2020-11-30 19:42

Using webpack, I\'m trying to import isEqual since lodash seems to be importing everything. I\'ve tried doing the following with no success:

imp         


        
7条回答
  •  广开言路
    2020-11-30 19:57

    If you just want to include isEqual and not the rest of the lodash functions (useful for keeping your bundle size small), you can do this in ES6;

    import isEqual from 'lodash/isEqual'
    

    This is pretty much the same as what's described in the lodash README, except that there they use require() syntax.

    var at = require('lodash/at');
    

提交回复
热议问题