将自己写的代码进行闭包封装

 

引用Zepto时,为防止$与jQuery或其他JS库的$冲突,对Zepto中的$进行闭包

 

 1 <script src="js/zepto.min.js"></script>
 2 <script type="text/javascript">
 3 $(function($){
 4     var clientWidth=$(window).width();
 5     var clientHeight=$(window).height();
 6     $('.inner').css({'width': clientWidth, 'height': clientHeight + 'px'});
 7 
 8     var swiper = new Swiper('.swiper-container', {
 9         direction: 'vertical',
10         resistanceRatio:0
11     });
12 })(zepto);

 

posted @ 2016-09-03 12:10  竹立荷塘  阅读(406)  评论(0编辑  收藏  举报