使用Modernizr加载脚本...不起作用 [英] Loading Scripts Using Modernizr... Not Working
本文介绍了使用Modernizr加载脚本...不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在尝试使用yepnope的Modernizr版本加载脚本时遇到问题,无法理解它们为何不同.如果我使用yep nope加载脚本,则效果很好:
I'm having problems trying to load scripts using the Modernizr version of yepnope and can't get my head around why they are different. If I load the scripts using yep nope it works fine:
<script type="text/javascript" src="/js/yepnope.1.0.2-min.js"></script>
<script type="text/javascript">
yepnope([
'/js/fancy-box-2.0.4/jquery.fancybox.css',
'/js/jquery-1.7.min.js',
'/js/jquery.form-defaults.js',
'/js/jquery.cycle.all.js',
'/js/jquery.easing.1.3.js',
'/js/fancy-box-2.0.4/jquery.fancybox.js',
'/js/functions.js',
'http://use.typekit.com/uoy8fub.js'
]);
</script>
但是,如果我尝试使用yep nope的Modernizr打包版本,则无法加载任何内容...帮助吗?
But if I trying using the Modernizr packaged version of yep nope I can't get anything to load... Help?
<script type="text/javascript" src="/js/modernizr-2.0.6.js"></script>
<script type="text/javascript">
Modernizr.load([
'/js/fancy-box-2.0.4/jquery.fancybox.css',
'/js/modernizr-2.0.6.js',
'/js/jquery-1.7.min.js',
'/js/jquery.form-defaults.js',
'/js/jquery.cycle.all.js',
'/js/jquery.easing.1.3.js',
'/js/fancy-box-2.0.4/jquery.fancybox.js',
'/js/functions.js',
'http://use.typekit.com/uoy8fub.js'
]);
</script>
推荐答案
更新:为了支持直接使用YepNope.js,在3.0版中已弃用Modernizr.load
.
值得注意的是,Modernizr.load仅使用yepnope库,并且它们是可互换的.例如
UPDATE: Modernizr.load
has been deprecated in version 3.0 in favour of using YepNope.js directly.
It's worth noting that Modernizr.load just uses the yepnope library and they are interchangeable. e.g.
yepnope({
test : Modernizr.geolocation,
yep : 'normal.js',
nope : ['polyfill.js', 'wrapper.js']
});
Modernizr.load({
test : Modernizr.geolocation,
yep : 'normal.js',
nope : ['polyfill.js', 'wrapper.js']
});
您可以尝试:
Modernizr.load({
load: [
'/js/fancy-box-2.0.4/jquery.fancybox.css',
'/js/jquery-1.7.min.js',
'/js/jquery.form-defaults.js',
'/js/jquery.cycle.all.js',
'/js/jquery.easing.1.3.js',
'/js/fancy-box-2.0.4/jquery.fancybox.js',
'/js/functions.js',
'http://use.typekit.com/uoy8fub.js'
]
});
这篇关于使用Modernizr加载脚本...不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文