安装常用依赖

1.lodash里面有很多工具类,排序,节流,防抖等

npm i -- save lodash

使用:导入到项目中

import  _  from  'lodash'

_.orderBy(list(代表数组),'like(代表要排序的字段)','desc(代表倒序排列)')

_.orderBy(list,'like','desc')

 

2.classnames工具优化类名控制

安装

npm install classnames

使用:导入到项目中

import classnames from 'classnames'

react传统动态控制样式,不清晰作用

<span className={`nav-item   ${type==item.type && 'active'}`}></span>

react使用classnames动态控制样式

<span className={classnames(‘nav-item’,{active:type==item.type})}></span>

 

3.uuid生成随机id

官网链接  :  https://www.npmjs.com/package/uuid/v/8.3.0

安装

npm install uuid

使用:导入到项目中

import { v4 as uuidv4 } from 'uuid';

在使用的地方调用

uuidv4()

 

posted @ 2023-11-08 15:57  小闫的姑娘  阅读(19)  评论(0编辑  收藏  举报