dependencies
1. whatwg-fetch
有些瀏覽器不支持fetch API傻挂,可以使用這個polyfill亿乳;fetch-ie8
主要支持的是IE8瀏覽器使用Fetch API漓帚。
安裝:npm install whatwg-fetch --save
or bower install fetch
使用:
在webpack中使用: entry: ['whatwg-fetch', ...]
在js文件中引入 import 'whatwg-fetch'
2. qrcode
用于將一些URL晃择、文字仰迁、emojis等生成二維碼,并將二維碼保存成圖片佃扼。
安裝:npm install qrcode --save
or bower install qrcode
使用:
var QRCode = require('qrcode');
QRCode.toDataURL(url, function (err, url) {});
3. js-cookie
顧名思義是操作cookie的兵迅,有了這個庫讓我們對cookie進行增刪改查方便了很多。
安裝:npm install js-cookie --save
or bower install js-cookie
使用:
import Cookie from 'js-cookie';
Cookies.set('name', 'sherry', { expires: 7, path: '' });
4.cpr
用來將一個文件夾的文件拷貝到另一個文件夾例衍。
安裝: npm install cpr --save
使用:
var cpr = require('cpr');
//or
var cpr = require('cpr').cpr;
cpr('/path/from', '/path/to', {
deleteFirst: true, //Delete "to" before
overwrite: true, //If the file exists, overwrite it
confirm: true //After the copy, stat all the copied files to make sure they are there
}, function(err, files) {
//err - The error if any (err.list might be available with an array of errors for more detailed information)
//files - List of files that we copied
});
5. ua-parser-js
這個庫主要用于獲取瀏覽器的一些信息昔期。
安裝: npm install ua-parser-js --save
使用:
var parser = require('ua-parser-js');
var parser = new UAParser();
var os = parser.getOS().name;
var browser = parser.getBrowser().name;
var brover = parser.getBrowser().major;
6.[nprogress] (https://www.npmjs.com/package/nprogress)
devDependencies
1. ora
如圖所以,在打包編譯的時候可以用這個庫佛玄,圖中轉(zhuǎn)動的loading圖案就是這個庫的效果硼一。這在編譯的時候相當(dāng)于一種反饋,不至于不知道發(fā)生了什么梦抢。
安裝:
npm install --save ora
使用:
const ora = require('ora');
const spinner = ora('Loading unicorns');
spinner.start();
......
spinnner.stop();
2.shelljs
有了這個庫般贼,你可以在其他平臺(比如Windows/Linux/OS X)使用Unix平臺的shell命令。
安裝:npm install [-g] shelljs
使用:
var shell = require('shelljs');
// Copy files to release dir
shell.rm('-rf', 'out/Release');
shell.cp('-R', 'stuff/', 'out/Release');
// Replace macros in each .js file
shell.cd('lib');
3.preprocess
用來預(yù)處理一些HTML,JS文件
安裝: npm install --save preprocess
使用:
<head>
<title>Your App</title>
<!-- @if NODE_ENV='production' -->
<script src="some/production/lib/like/analytics.js"></script>
<!-- @endif -->
</head>
<body>
<!-- @ifdef DEBUG -->
<h1>Debugging mode - <!-- @echo RELEASE_TAG --> </h1>
<!-- @endif -->
<p>
<!-- @include welcome_message.txt -->
</p>
</body>
4.log4js
未完待續(xù)。哼蛆。蕊梧。