备案 控制台
学习
实践
活动
专区
工具
TVP
写文章
专栏首页 前端公虾米 新手前端莫慌,握紧救命稻草(建议收藏)
1 0

海报分享

新手前端莫慌,握紧救命稻草(建议收藏)

新手阶段的前端面临的最大问题就是: " 😥这个咋做? ", 这个阶段的前端自己实现交互功能基本是不可能的, 那怎么体现价值呢?

我给个建议: " 不会写还不会用吗? ", 其实js发展这么多年,常见的功能在github上都是可以找到的, 下面我就给大家拿出我收藏多年的" 救命插件 "!

copy-to-clipboard (剪贴板)

var clipboard = new ClipboardJS('.btn');

https://github.com/zenorocha/clipboard.js

FileSaver (文件另存为)

var FileSaver = require('file-saver');
var blob = new Blob(["Hello, world!"], {type: "text/plain;charset=utf-8"});
FileSaver.saveAs(blob, "hello world.txt");

https://github.com/eligrey/FileSaver.js

excel-js (xlsx转换)

var workbook = XLSX.utils.table_to_book(document.getElementById('table'));

https://github.com/SheetJS/js-xlsx

jsPDF (生成pdf)

var doc = new jsPDF();
doc.text('Hello world!', 10, 10);
doc.save('a4.pdf');

https://github.com/MrRio/jsPDF

fileApi (上传, 支持进度/分段)

var uploadButton = document.getElementById('uploadButton');
FileAPI.event.on(uploadButton, 'change', function (evt){
}

https://github.com/mailru/FileAPI

swipe(轮播)

<div class="swiper-container">
    <div class="swiper-wrapper">
        <div class="swiper-slide">第一页</div>
        <div class="swiper-slide">第二页</div>
        <div class="swiper-slide">第三页</div>
</div>
new Swiper ('#my-swiper');

https://github.com/nolimits4web/swiper

qrcodejs(二维码生成器)

var qrcode = new QRCode(document.getElementById("qrcode"), {
	text: "你好js!",
	width: 128,
	height: 128,
	colorDark : "#000000",
	colorLight : "#ffffff",
	correctLevel : QRCode.CorrectLevel.H
});

https://github.com/davidshimjs/qrcodejs

autosize (textara高度自适应文字)

autosize(document.querySelectorAll('textarea'));

https://github.com/jackmoore/autosize

shake.js (监听手机震动)

var myShakeEvent = new Shake({
    threshold: 15,
    timeout: 1000
window.addEventListener('shake', ()=>{
	// 摇晃触发
}, false);

https://github.com/alexgibson/shake.js 提示 : 适合用来做"摇一摇"的活动页面活游戏

dayjs (时间格式转换)

dayjs('2018').fromNow(); // 1年前

https://github.com/iamkun/dayjs

progressbar (进度条)

var bar = new ProgressBar.Circle(container, {
  strokeWidth: 6,
  easing: 'easeInOut',
  duration: 1400,
  color: '#FFEA82',
  trailColor: '#eee',
  trailWidth: 1,
  svgStyle: null
bar.animate(1.0);

https://github.com/kimmobrunfeldt/progressbar.js

文章分享自微信公众号:
前端公虾米

本文参与 腾讯云自媒体分享计划 ,欢迎热爱写作的你一起参与!

作者: 铁皮饭盒
原始发表时间: 2019-10-22
如有侵权,请联系 cloudcommunity@tencent.com 删除。