lodash

前端资源借鉴

♀尐吖头ヾ 提交于 2020-04-02 21:55:18
函数库 Lodash https://github.com/lodash/lodash 动画库 Animate.css https://daneden.github.io/animate.css/ wow.js: http://mynameismatthieu.com/WOW/ 滚动库 BetterScroll:https://ustbhuangyi.github.io/better-scroll/#/examples/vertical-scroll/en 轮播图 Swiper:https://www.swiper.com.cn/demo/index.html iSlider:http://eux.baidu.com/iSlider/demo/index_chinese.html#demo 弹出框 easyDialog http://www.h-ui.net/easydialog-v2.0/index.html 下拉框 select2 https://select2.org/ 级联选择器 ustbhuangyi/picker https://didi.github.io/cube-ui/#/zh-CN/docs/introduction 颜色选择器 Bootstrap Colorpicker https://github.com/farbelous/bootstrap

Find index of object in javascript using its property name

人走茶凉 提交于 2020-03-26 06:38:33
问题 I want to find Index of javascript array of objects using objects property name. My code is :- const checkbox = [{'mumbai': true},{'bangalore': true},{'chennai': true},{'kolkata': true}]; How can i find index of chennai? Can i acheive using lodash? 回答1: You can use .findIndex() const checkbox = [ {'mumbai': true}, {'bangalore': true}, {'chennai': true}, {'kolkata': true} ]; const finder = (arr, key) => arr.findIndex(o => key in o); console.log(finder(checkbox, 'chennai')); console.log(finder

vue学习日记10

a 夏天 提交于 2020-03-22 04:49:42
Echart 还是先下载安装 npm install echarts --save  echarts官网 https://www.echartsjs.com/zh/tutorial.html#5%20%E5%88%86%E9%92%9F%E4%B8%8A%E6%89%8B%20ECharts vue也有封装好的echarts,在使用 echarts 生成图表时,经常需要做繁琐的数据类型转化、修改复杂的配置项,v-charts 的出现正是为了解决这个痛点。基于 Vue2.0 和 echarts 封装的 v-charts 图表组件,只需要统一提供一种对前后端都友好的数据格式设置简单的配置项,便可轻松生成常见的图表。 v-charts官网 https://v-charts.js.org/#/ 以echarts为例: <template> <div> <div ref="chartDom" style="height:300px"></div> </div> </template> <script> import echarts from "echarts"; import { addListener, removeListener } from "resize-detector"; import debounce from "loadsh/debounce"; export

JS操作小记

删除回忆录丶 提交于 2020-02-28 14:42:42
this.Phenomenon.forEach(element => { if (element.value3 == this.prvphe) { this.Reason1 = element.Children } }) const obj1 = { id: 100, value4: '其他' } this.Reason1.push(obj1) //forEach循环可以取到数组中对象 取到对象后就可以进行下一层数组的赋值或者更改某个值 下面是数组的push方法新增对象 import _ from 'lodash' this.CloneReason2 = _.cloneDeep(this.Reason2) //复制数组可以用lodash //删除可以用splice this.CloneReason2.splice(2, 3) //lodash的话可以用drop等 但是要重新在赋值一次 this.CloneReason2 = _.drop(this.CloneReason2, 10) 来源: https://www.cnblogs.com/cdjbolg/p/12376822.html

how to find difference between two array using lodash/underscore in nodejs

大兔子大兔子 提交于 2020-02-27 14:10:10
问题 I have two arrays of arrays and am trying to find the difference. var a = [[ 11, 24, 28, 38, 42, 44 ], [ 7, 19, 21, 22, 29, 38 ], [ 2, 21, 27, 30, 33, 40 ], [ 6, 11, 12, 21, 34, 48 ], [ 1, 10, 17, 31, 35, 40 ], [ 1, 18, 26, 33, 36, 45 ], [ 15, 21, 22, 24, 38, 46 ], [ 5, 17, 21, 27, 29, 41 ], [ 3, 7, 12, 16, 20, 28 ], [ 9, 12, 13, 18, 30, 37 ], [ 3, 19, 21, 31, 33, 46 ], [ 6, 11, 16, 18, 20, 34 ], [ 1, 3, 11, 13, 24, 28 ], [ 12, 13, 16, 40, 42, 46 ], [ 1, 3, 5, 36, 37, 41 ], [ 14, 15, 23, 24,

webpack 代码分离

£可爱£侵袭症+ 提交于 2020-02-27 05:24:11
本指南扩展了 起步 和 管理输出 中提供的示例。请确保您至少已熟悉其中提供的示例。 代码分离是 webpack 中最引人注目的特性之一。此特性能够把代码分离到不同的 bundle 中,然后可以按需加载或并行加载这些文件。代码分离可以用于获取更小的 bundle,以及控制资源加载优先级,如果使用合理,会极大影响加载时间。 有三种常用的代码分离方法: 入口起点:使用 entry 配置手动地分离代码。 防止重复:使用 CommonsChunkPlugin 去重和分离 chunk。 动态导入:通过模块的内联函数调用来分离代码。 1. 入口起点(entry points) 这是迄今为止最简单、最直观的分离代码的方式。不过,这种方式手动配置较多,并有一些陷阱,我们将会解决这些问题。先来看看如何从 main bundle 中分离另一个模块: project webpack-demo |- package.json |- webpack.config.js |- /dist |- /src |- index.js + |- another-module.js |- /node_modules another-module.js import _ from 'lodash'; console.log( _.join(['Another', 'module', 'loaded!'], ' ') );

Merge specific properties of objects together with JavaScript

亡梦爱人 提交于 2020-02-16 11:30:12
问题 So I have an array of objects like so: [ { name: "Joe Smith", job: "Janitor", age: 35, id: "3421" }, { name: "George Henderson", job: "CEO", age: 43, id: "5098" }, { name: "Joe Smith", job: "Cook", age: 35, id: "3421" }, { name: "Sam Doe", job: "Technician", age: 22, id: "1538" }, { name: "Joe Smith", job: "Dishwasher", age: 35, id: "3421" } ] As you can see, Joe Smith has three jobs. What I want to do is to combine all of his jobs into one object like so: { name: "Joe Smith", job: "Janitor,

Convert object key to array with values number of key with Lodash [duplicate]

风格不统一 提交于 2020-02-16 08:39:28
问题 This question already has answers here : How to produce an array from an object where the number of elements is determined by Object.values? (7 answers) Closed 10 days ago . I have an object with products: products: { bread: 1, milk: 2, cheese: 2, chicken: 1, } I would like to have an array with the name of products like this: products: ['bread', 'milk', 'milk', 'cheese', 'cheese', 'chicken'] I was trying to use lodash with reduce method but I don't know how to "multiply" this product in

Using lodash in Angular 4

*爱你&永不变心* 提交于 2020-02-13 08:01:56
问题 I have previously used lodash in my Angular 4 application by simply importing it and using it as shown here: import lodash from 'lodash'; public getSubtotal() : number { return lodash.sumBy(this.cartItems, function(item) { return item.product.price * item.item.quantity; }) } I am once again trying to use lodash similarly but am getting an error that lodash is undefined. import lodash from 'lodash'; lodash.indexOf([1, 2, 1, 2], 2); I get the following error: ERROR TypeError: Cannot read

Using lodash in Angular 4

情到浓时终转凉″ 提交于 2020-02-13 08:00:27
问题 I have previously used lodash in my Angular 4 application by simply importing it and using it as shown here: import lodash from 'lodash'; public getSubtotal() : number { return lodash.sumBy(this.cartItems, function(item) { return item.product.price * item.item.quantity; }) } I am once again trying to use lodash similarly but am getting an error that lodash is undefined. import lodash from 'lodash'; lodash.indexOf([1, 2, 1, 2], 2); I get the following error: ERROR TypeError: Cannot read