React中为什么最好不要用数组的index作为key

React中为什么最好不用数组的index作为key 当你在写或者在读别人渲染列表的React代码的时候,很容易看到使用index作为Key的情况,比如: JavaScript list.map((row, index)=( <Item key={index} )) 看起来不错,还可以避免React的Key Warning。但是,这样做却...
25 days ago
159 1 0

理解 JavaScript 中的 microtasks 和 macrotasks(微任务和宏任务)

如果一段JavaScript代码中包含了setTimeout几乎所有的前端同学都知道其代码会被延迟(异步)执行,但是如果代码中同时出现了setTimeout、await以及Promise resolve的话大家还能说出来他们的先后执行顺序么?先抛出一个网上流传的前端面试题,主要考察的知识点是异步asyncawait,setTimeout,Promise resolve...
4 months ago
340 1 0

配置全局.gitignore文件

很多时候,在审查代码的时候,会看到.gitignore文件中这样的提交: bash composer.lock package.lock .vscode 其中.vscode是vscode的配置文件,如果所有人都把自己的环境编辑器配置放到.gitignore中的话,就会导致.gitignore文件很长很难维护。为了保持项目的干净整洁,可以使用全局.git...
4 months ago
305 3 0

如何使用Canvas实现一个时间控件

前段时间在一个分享上提及到了我们的时间穿梭控件,分享之后很多同学在Github的Issue中留言想了解该控件的具体开发过程,利用周末的时间将该控件单独重新写成一个Demo,和大家分享一下具体的技术实现细节。 重新整理的控件开源在Github上 [https:...
2020-03-22
1384 5 0

从地图看疫情

Recently we released a map that can dynamically show the trend of Coronavirus disease 2019 (COVID-19) epidemics: https:www.mapbox.cncoronavirusmap Combi...
2020-02-23
3460 3 0

从零开始做点阵地图

Recently, many people have seen the map I put on my home page and asked me how I did it or what plug-ins I used. ![e7c39be65f0158f921530926ca16b612.gif](https:cdn.zhuwenlong.comuploadimageScreen...
2019-08-30
3004 14 0

JavaScript数字前补0小技巧

A friend who often processes financial data may encounter a need to convert a string of a fixed length to a fixed length, such as 123 = 000123. Usually we will try this: let num = 123; c...
2019-01-10
2255 4 230

使用Travis-ci自动SSH部署代码

We know that the continuous integration tools such as Travis-ci can help us to do unit tests after the code is submitted. Is there any way to automatically deploy the code through SSH to the traget ma...
2018-12-27
3864 4 0

像大神一样写代码之代码质量控制

Mofei超爱开源,最近接触了不少大神的开源项目,特别羡慕这些项目的代码质量控制,再加上公司最近也在强调代码质量,在挖坑、填坑的路上总结出一些经验和大家分享。 今天想聊的是其中的持续集成、单元测试和代码覆盖率的部分。 ![article image from 'zhuwenlong.com'](https:static.zhuwenlong.comuploadimage154...
2018-11-13
3470 8 1

Web APP/JavaScript 下载大文件解决方案

With the increasing ability of browsers to process data and the popularity of Web APP, many times we will need to download and save the data processed by the browser: such as the report generation CSV...
2018-07-13
7456 11

mapv-Editor 预发布版简介

<iframe height=498 width=800 src='https:player.youku.comembedXMzE4MDYwMjc0NA==' frameborder=0 'allowfullscreen'<iframe mapv-Editor是一个基于mapv引擎的一款在线编辑器,目前还...
2017-11-29
2758 4 5

使用JavaScript Canvas模拟绘制带斑马线的十字路口及其细节

Recently, In my work, I try to draw a crossroad with zebra lines and traffic light directions. It's quite tricky and takes me lots of time. So, Here is a paragraph to record and share the experience. ...
2017-11-06
3847 7 203