正确的方式导入lodash

编程入门 行业动态 更新时间:2024-10-15 10:20:43
本文介绍了正确的方式导入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

本文发布于:2023-10-28 04:31:15,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1535527.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:正确   方式   lodash

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!