开发中会遇到一些防抖和节流等需求,lodash已经写好了,直接引入使用
官网地址:https://www.lodashjs.com/
npm i lodash
安装后 在main.js中引入
import _ from 'lodash'
注册到全局
Vue.prototype.$_ = _ ;
举例:多维数组转一维
let arr = [1,2,3,4,[5,6,7,[8,9]]];
let newArr = this.$_flattenDeep(arr) ;
就可以得到 - > [1,2,3,4,5,6,7,8,9] ;
非常方便
uniApp 使用lodash插件
于 2021-09-18 10:04:53 首次发布