npm 检测浏览器的支持度
npm install caniuse
var query = require('caniuse').query,
result;
result = query('transforms3d', {name:'android', version: '2.3'});
// query result:
// -2 : NOT supported
// -1 : NOT supported, but has polyfill available
// 0 : unknown
// 1 : partially supported, and vendor prefixed
// 2 : partially supported
// 3 : supported, and vendor prefixed
// 4 : supported
if (result > 2) {
console.log('Fully supported!');
}
caniuse命令行工具 而且caniuse提供了命令行工具。
npm install -g caniuse-cmd
注意:如果使用的是Windows系统,需要在Git的命令行执行上述命令。否则会报Git Not Found的错。
基本用法:caniuse 特性
如运行:caniuse websocket
查看帮助:caniuse --help
caniuse 默认查看的是PC浏览器的兼容性,它也提供了查看在移动端的数据。执行命令:caniuse -m websocket
caniuse项目的github
caniuse-cmd Npm包
官方网站:https://caniuse.com/