正确的方式导入lodash [英] Correct way to import lodash

查看:710
本文介绍了正确的方式导入lodash的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

下面我有一个拉取请求反馈,只是想知道导入lodash的正确方法是哪种方式?

I had a pull request feedback below, just wondering which way is the correct way to import lodash?


你最好这样做import来自'lodash / has'..对于lodash(v3)的早期版本
,它本身非常重,我们应该只导入
a specidic模块/函数而不是导入整个lodash
库。不确定更新的版本(v4)。

You'd better do import has from 'lodash/has'.. For the earlier version of lodash (v3) which by itself is pretty heavy, we should only import a specidic module/function rather than importing the whole lodash library. Not sure about the newer version (v4).



import has from 'lodash/has';

vs

import { has } from 'lodash';

谢谢

推荐答案

import来自'lodash / has'; 更好,因为lodash将所有函数保存在一个文件中,所以不要导入整个'lodash'库在100k,最好只导入lodash的函数,可能是2k。

import has from 'lodash/has'; is better because lodash holds all it's functions in a single file, so rather than import the whole 'lodash' library at 100k, it's better to just import lodash's has function which is maybe 2k.

这篇关于正确的方式导入lodash的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆