向modernizr添加测试的正确方法是什么

What is the proper method to add tests to modernizr?

本文关键字:方法 是什么 modernizr 添加 测试      更新时间:2023-09-26

测试已经存在于github repo中,但当我试图将其包含在页面上时,我会遇到错误,因此我不确定如何将其包含到文档中。在我的html <head>标签中,我链接modernizr脚本,然后链接到我要添加的测试:

<script src="js/modernizr-2.5.3-min.js"></script>
<script src="js/css-pointerevents.js"></script>

css-pointerevents.js

当我现在加载页面时,我得到一个javascript错误:Uncaught TypeError: Object #<Object> has no method 'addTest',它必须是对css-pointervernts.js(Modernizr.addTest('pointerevents', function(){)的第一行的引用

这是因为Modernizr的默认基本构建中不包括addTest功能。需要特别添加(在可扩展性下)http://modernizr.com/download/