记录一些 npm包

1.  file-saver(文件下载)  网址:https://www.npmjs.com/package/file-saver

安装:

npm install file-saver --save

引用:

import { saveAs } from 'file-saver';

用法:

// txt
var
FileSaver = require('file-saver'); var blob = new Blob(["Hello, world!"], {type: "text/plain;charset=utf-8"}); FileSaver.saveAs(blob, "hello world.txt");
// 图片什么的
FileSaver.saveAs("https://httpbin.org/image""image.jpg");
//
canvas
 var canvas document.getElementById("my-canvas");
 canvas.toBlob(function(blob{
    saveAs(blob"pretty image.png");
 });
 //File
 var file new File(["Hello, world!"]"hello world.txt"{type"text/plain;charset=utf-8"});
 FileSaver.saveAs(file);
 

 

2. 生成二维码  

QRCode
3. 一维码 
JsBarcode
posted @ 2020-09-19 11:19  诺谟  阅读(177)  评论(0编辑  收藏  举报
你好啊