gpt4 book ai didi

javascript - SwipeJS 在 JQuery-Mobile Web 应用程序中不起作用

转载 作者:行者123 更新时间:2023-11-28 11:36:40 25 4
gpt4 key购买 nike

我尝试让 SwipeJS (www.swipejs.com) 在我的 JQuery-Mobile 网站上运行。

  <script src="bin/js/swipe.js"></script>      
<style>
/* Swipe 2 required styles */
.swipe {
overflow: hidden;
visibility: hidden;
position: relative;
}
.swipe-wrap {
overflow: hidden;
position: relative;
}
.swipe-wrap > div {
float:left;
width:100%;
position: relative;
}
/* END required styles */
</style>

--

<!-- PAGE -->
<div data-role="page" id="pagec" data-theme="a">
<div data-role="header" data-id="head2" data-position="fixed" data-tap-toggle="false">
<div data-role="navbar">
<ul>
<?php getNav(); ?>
</ul>
</div>
</div>
<div data-role="content">
<!-- SWIPE -->
<div id='mySwipe' style='max-width:500px;margin:0 auto' class='swipe'>
<div class='swipe-wrap'>
<div><b>0</b></div>
<div><b>1</b></div>
<div><b>2</b></div>
<div><b>3</b></div>
<div><b>4</b></div>
<div><b>5</b></div>
<div><b>6</b></div>
<div><b>7</b></div>
<div><b>8</b></div>
<div><b>9</b></div>
<div><b>10</b></div>
<div><b>11</b></div>
<div><b>12</b></div>
<div><b>13</b></div>
<div><b>14</b></div>
<div><b>15</b></div>
<div><b>16</b></div>
<div><b>17</b></div>
<div><b>18</b></div>
<div><b>19</b></div>
<div><b>20</b></div>
</div>
</div>



<div style='text-align:center;padding-top:20px;'>

<button onclick='mySwipe.prev()'>prev</button>
<button onclick='mySwipe.next()'>next</button>

</div>
<?php getContent(); ?>
<!-- //SWIPE -->
</div>
<div data-role="footer" data-position="fixed" data-tap-toggle="false">
<?php getForm(); ?>
</div>
</div>
<!-- //PAGE -->
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script src='swipe.js'></script>
<script>

// pure JS
var elem = document.getElementById('mySwipe');
window.mySwipe = Swipe(elem, {
// startSlide: 4,
// auto: 3000,
// continuous: true,
// disableScroll: true,
// stopPropagation: true,
// callback: function(index, element) {},
// transitionEnd: function(index, element) {}
});

// with jQuery
// window.mySwipe = $('#mySwipe').Swipe().data('Swipe');

</script>

swipe.js 链接在包含的 header.php 中,并且还添加了所需的 css。虽然一切都按照说明中的描述实现,但它不起作用。

演示运行良好...

我做错了什么?

最佳答案

我将代码放在头部,然后 TADAAAAA... 它起作用了。

 $(document).on('pageshow', function () {
var elem = document.getElementById('content_swipe');
window.content_swipe = Swipe(elem, {
// startSlide: 1,
// auto: 3000,
// continuous: true,
// disableScroll: true,
// stopPropagation: true,
// callback: function(index, element) {},
// transitionEnd: function(index, element) {}
});
// with jQuery
// window.mySwipe = $('#mySwipe').Swipe().data('Swipe');
});

关于javascript - SwipeJS 在 JQuery-Mobile Web 应用程序中不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20887418/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com