Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

浏览器特性检测工具:Modernizr #31

Open
youngwind opened this issue Feb 29, 2016 · 0 comments
Open

浏览器特性检测工具:Modernizr #31

youngwind opened this issue Feb 29, 2016 · 0 comments

Comments

@youngwind
Copy link
Owner

原因

我在使用chart.js的时候碰到不少IE8的兼容性问题,其中包括动画问题 #29
chart.js官方文档推荐使用Modernizr来进行浏览器特性检测,进而决定是否显示动画。

使用方法

下载

Modernizr可以检测很多浏览器的特性,在它的官网可以随意勾选你所需要的检测特性,然后生成js文件,比如这次我只需要检测canvas,所以大概这样。
2016-02-29 6 57 44

使用

引入了modernize.custom.js文件之后,如果要检测某个特性,只需要这样。

 if (Modernizr.awesomeNewFeature) {
    console.log('this feature support!');
  } else {
    console.log('this feature do not support!');
  }

PS:开发环境中也可以直接选择development build,这样就包含所有特性的检测了。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant