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

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

SecLists
SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

WebStorm Mac version
Useful JavaScript development tools

Atom editor mac version download
The most popular open source editor

EditPlus Chinese cracked version
Small size, syntax highlighting, does not support code prompt function

DVWA
Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software