10 latest and practical JS tool libraries in 2022 [Recommended]
This article will share with you the 10 most popular practical JS tool libraries, which are used in 80% of projects. Come and collect them for use. I hope it will be helpful to everyone!
The important thing that distinguishes masters from ordinary people is that they are good at using tools and leave more time for planning and thinking. The same goes for writing code. If you use the tools well, you will have more time to plan the architecture and overcome difficulties. Today I will share with you the most popular js tool library currently. If you find it useful, please give it a thumbs up!
1. Day.js
A minimalist JavaScript library for processing time and date. The API design remains the same as Moment.js, but the size is only 2KB.
npm install dayjs
Basic usage
import dayjs from 'dayjs' dayjs().format('YYYY-MM-DD HH:mm') // => 2022-01-03 15:06 dayjs('2022-1-3 15:06').toDate() // => Mon Jan 03 2022 15:06:00 GMT+0800 (中国标准时间)
2. qs
A lightweight JavaScript library for url parameter conversion
npm install qs
Basic usage
import qs from 'qs' qs.parse('user=tom&age=22') // => { user: "tom", age: "22" } qs.stringify({ user: "tom", age: "22" }) // => user=tom&age=22
3. js-cookie
A simple, lightweight js API for handling cookies
npm install js-cookie
Basic usage
import Cookies from 'js-cookie' Cookies.set('name', 'value', { expires: 7 }) // 有效期7天 Cookies.get('name') // => 'value'
4. flv.js
bilibili is an open source html5 flash video player that makes the browser FLV can be played without the help of flash plug-in, which is currently the mainstream live broadcast and on-demand solution.
npm install flv.js
Basic usage
<video autoplay controls width="100%" height="500" id="myVideo"></video> import flvjs from 'flv.js' // 页面渲染完成后执行 if (flvjs.isSupported()) { var myVideo = document.getElementById('myVideo') var flvPlayer = flvjs.createPlayer({ type: 'flv', url: 'http://localhost:8080/test.flv' // 视频 url 地址 }) flvPlayer.attachMediaElement(myVideo) flvPlayer.load() flvPlayer.play() }
5. vConsole
A lightweight, scalable front-end development for mobile web pages or debug panel. If you are still struggling with how to debug code on your mobile phone, use it.
npm install vconsole
Basic Usage
import VConsole from 'vconsole' const vConsole = new VConsole() console.log('Hello world')
Recently I have found that many guys only collect and don’t like. This is not a good habit. Rejecting free prostitution starts with you and me! Come move with me and give me a like first! Collect again!
6. Animate.css
A cross-browser css3 animation library with many typical css3 animations built-in, with good compatibility and easy use.
npm install animate.css
Basic usage
<h1 id="An-nbsp-animated-nbsp-element">An animated element</h1> import 'animate.css'
7. animejs
A powerful Javascript animation library. It can work with CSS3 properties, SVG, DOM elements, and JS objects to produce various high-performance, smooth transition animation effects.
npm install animejs
Basic usage
<div class="ball" style="width: 50px; height: 50px; background: blue"></div> import anime from 'animejs/lib/anime.es.js' // 页面渲染完成之后执行 anime({ targets: '.ball', translateX: 250, rotate: '1turn', backgroundColor: '#F00', duration: 800 })
8, lodash.js
A consistent, modular, high-performance JavaScript Practical tool library
npm install lodash
Basic usage
import _ from 'lodash' _.max([4, 2, 8, 6]) // 返回数组中的最大值 => 8 _.intersection([1, 2, 3], [2, 3, 4]) // 返回多个数组的交集 => [2, 3]
9, mescroll.js
An exquisite, on the H5 side The running pull-down refresh and pull-up loading plug-ins are mainly used in scenarios such as list paging and refreshing.
npm install mescroll.js
Basic usage (vue component)
<template> <div> <mescroll-vue ref="mescroll" :down="mescrollDown" :up="mescrollUp" @init="mescrollInit" > <!--内容...--> </mescroll-vue> </div> </template> <script> import MescrollVue from 'mescroll.js/mescroll.vue' export default { components: { MescrollVue }, data() { return { mescroll: null, // mescroll实例对象 mescrollDown: {}, //下拉刷新的配置 mescrollUp: { // 上拉加载的配置 callback: this.upCallback }, dataList: [] // 列表数据 } }, methods: { // 初始化的回调,可获取到mescroll对象 mescrollInit(mescroll) { this.mescroll = mescroll }, // 上拉回调 page = {num:1, size:10}; num:当前页 ,默认从1开始; size:每页数据条数,默认10 upCallback(page, mescroll) { // 发送请求 axios .get('xxxxxx', { params: { num: page.num, // 当前页码 size: page.size // 每页长度 } }) .then(response => { // 请求的列表数据 let arr = response.data // 如果是第一页需手动置空列表 if (page.num === 1) this.dataList = [] // 把请求到的数据添加到列表 this.dataList = this.dataList.concat(arr) // 数据渲染成功后,隐藏下拉刷新的状态 this.$nextTick(() => { mescroll.endSuccess(arr.length) }) }) .catch(e => { // 请求失败的回调,隐藏下拉刷新和上拉加载的状态; mescroll.endErr() }) } } } </script> <style scoped> .mescroll { position: fixed; top: 44px; bottom: 0; height: auto; } </style>
10. Chart.js
A set of simple, Clean and attractive JavaScript chart library
npm install chart.js
Basic usage
<canvas id="myChart" width="400" height="400"></canvas> import Chart from 'chart.js/auto' // 页面渲染完成后执行 const ctx = document.getElementById('myChart') const myChart = new Chart(ctx, { type: 'bar', data: { labels: ['Red', 'Blue', 'Yellow', 'Green', 'Purple', 'Orange'], datasets: [ { label: '# of Votes', data: [12, 19, 3, 5, 2, 3], backgroundColor: [ 'rgba(255, 99, 132, 0.2)', 'rgba(54, 162, 235, 0.2)', 'rgba(255, 206, 86, 0.2)', 'rgba(75, 192, 192, 0.2)', 'rgba(153, 102, 255, 0.2)', 'rgba(255, 159, 64, 0.2)' ], borderColor: [ 'rgba(255, 99, 132, 1)', 'rgba(54, 162, 235, 1)', 'rgba(255, 206, 86, 1)', 'rgba(75, 192, 192, 1)', 'rgba(153, 102, 255, 1)', 'rgba(255, 159, 64, 1)' ], borderWidth: 1 } ] }, options: { scales: { y: { beginAtZero: true } } } })
Each of the above tool libraries was personally tested by myself, and the current company projects are basically in use. If you have any questions, please share them in the comment area. If you have other good tools, please share them. Let’s improve work efficiency together and defeat all evil capitalism
Finally, don’t forget to like it! Wish you riches in 2022! Gorgeous! Extremely thin!
Original address: https://juejin.cn/post/7048963605462515743
Author: Front-end A Fei
[Related recommendations: javascript Study tutorial】

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

How to use WebSocket and JavaScript to implement an online speech recognition system Introduction: With the continuous development of technology, speech recognition technology has become an important part of the field of artificial intelligence. The online speech recognition system based on WebSocket and JavaScript has the characteristics of low latency, real-time and cross-platform, and has become a widely used solution. This article will introduce how to use WebSocket and JavaScript to implement an online speech recognition system.

WebSocket and JavaScript: Key technologies for realizing real-time monitoring systems Introduction: With the rapid development of Internet technology, real-time monitoring systems have been widely used in various fields. One of the key technologies to achieve real-time monitoring is the combination of WebSocket and JavaScript. This article will introduce the application of WebSocket and JavaScript in real-time monitoring systems, give code examples, and explain their implementation principles in detail. 1. WebSocket technology

How to use WebSocket and JavaScript to implement an online reservation system. In today's digital era, more and more businesses and services need to provide online reservation functions. It is crucial to implement an efficient and real-time online reservation system. This article will introduce how to use WebSocket and JavaScript to implement an online reservation system, and provide specific code examples. 1. What is WebSocket? WebSocket is a full-duplex method on a single TCP connection.

Introduction to how to use JavaScript and WebSocket to implement a real-time online ordering system: With the popularity of the Internet and the advancement of technology, more and more restaurants have begun to provide online ordering services. In order to implement a real-time online ordering system, we can use JavaScript and WebSocket technology. WebSocket is a full-duplex communication protocol based on the TCP protocol, which can realize real-time two-way communication between the client and the server. In the real-time online ordering system, when the user selects dishes and places an order

JavaScript tutorial: How to get HTTP status code, specific code examples are required. Preface: In web development, data interaction with the server is often involved. When communicating with the server, we often need to obtain the returned HTTP status code to determine whether the operation is successful, and perform corresponding processing based on different status codes. This article will teach you how to use JavaScript to obtain HTTP status codes and provide some practical code examples. Using XMLHttpRequest

JavaScript and WebSocket: Building an efficient real-time weather forecast system Introduction: Today, the accuracy of weather forecasts is of great significance to daily life and decision-making. As technology develops, we can provide more accurate and reliable weather forecasts by obtaining weather data in real time. In this article, we will learn how to use JavaScript and WebSocket technology to build an efficient real-time weather forecast system. This article will demonstrate the implementation process through specific code examples. We

Introduction to the method of obtaining HTTP status code in JavaScript: In front-end development, we often need to deal with the interaction with the back-end interface, and HTTP status code is a very important part of it. Understanding and obtaining HTTP status codes helps us better handle the data returned by the interface. This article will introduce how to use JavaScript to obtain HTTP status codes and provide specific code examples. 1. What is HTTP status code? HTTP status code means that when the browser initiates a request to the server, the service

Usage: In JavaScript, the insertBefore() method is used to insert a new node in the DOM tree. This method requires two parameters: the new node to be inserted and the reference node (that is, the node where the new node will be inserted).