Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/72.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/jpa/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Jquery iScroll-未捕获引用错误:在索引中未定义myScroll,并且从webcore接收到过时的触摸事件操作_Jquery_Jquery Mobile_Iscroll4_Iscroll_Referenceerror - Fatal编程技术网

Jquery iScroll-未捕获引用错误:在索引中未定义myScroll,并且从webcore接收到过时的触摸事件操作

Jquery iScroll-未捕获引用错误:在索引中未定义myScroll,并且从webcore接收到过时的触摸事件操作,jquery,jquery-mobile,iscroll4,iscroll,referenceerror,Jquery,Jquery Mobile,Iscroll4,Iscroll,Referenceerror,我在我的levels页面中使用了iScroll,但不知何故,我的编辑器抱怨我的索引页面(另一个页面)中存在引用错误,而我没有使用iScroll。我在索引中搜索“myScroll”,但在索引中没有这样的词。由于该错误,在浏览器中工作的iScroll在Android emulator中不工作 09-04 08:31:06.249: E/Web Console(942): Uncaught ReferenceError: myScroll is not defined at file:///andro

我在我的levels页面中使用了iScroll,但不知何故,我的编辑器抱怨我的索引页面(另一个页面)中存在引用错误,而我没有使用iScroll。我在索引中搜索“myScroll”,但在索引中没有这样的词。由于该错误,在浏览器中工作的iScroll在Android emulator中不工作

09-04 08:31:06.249: E/Web Console(942): Uncaught ReferenceError: myScroll is not defined at file:///android_asset/www/index.html:1
如果我在模拟器中滑动,它会生成

09-04 15:58:57.318: W/webview(3045): Stale touch event ACTION_DOWN received from webcore; ignoring
index.html(我没有使用iScroll)


应用程序名称

级别页面(我使用的页面)


学习水平
  • zz
←上
  • 1
  • 二,
  • 三,
next→


$(文档).ready(函数(){
this.myScroll=$('#wrapper').iScroll({
是的,
动量:错,
hScrollbar:错,
onScrollEnd:函数(){
document.querySelector('#indicator>li.active')。className='';
document.querySelector('#indicator>li:n子项(+(this.currPageX+1)+')).className='active';
}
})
})

您已将
myScroll
变量绑定到文档。因此,您可以通过调用
document.myScroll
将其绑定到
窗口
,或者将
替换为
窗口
(或者将其删除),使其成为:

window.myScroll = $('#wrapper') ...
然后可以将其作为正则变量调用。

--Update------

再看一眼,$(“#包装器”).iScroll。。。来自安德而不是jQuery,我相信这会引起冲突

所以你可能想创建一个闭包,类似这样:

  (function($){
      $(document).ready(function() {
           this.myScroll = $('#wrapper').iScroll({
           //custom options here 
           });
      });
  })(ender);
 <div id="prev" onclick="myScroll.scrollToPage('prev', 0);return false"> stuff </div>
由于enders document.ready函数中的“this”指向窗口对象

您可以这样简单地传递内联事件处理程序:

  (function($){
      $(document).ready(function() {
           this.myScroll = $('#wrapper').iScroll({
           //custom options here 
           });
      });
  })(ender);
 <div id="prev" onclick="myScroll.scrollToPage('prev', 0);return false"> stuff </div>
东西

希望有帮助:)

所以我必须更改为window.myScroll=$(“#wrapper”).iScroll?Getting无法调用在处未定义的方法“scrollToPage”file:///android_asset/www/index.html:1. 你能给我看一套更完整的代码片段吗?谢谢。我遵循官方网站上安德的例子。当我更改代码(jquery部分)时,它将变为无法刷卡。它获取:09-04 14:27:14.318:E/Web控制台(2594):未捕获类型错误:无法在处调用未定义的方法“scrollToPage”file:///android_asset/www/index.html:1Appologies 由于错误地阅读了您的问题,请更新我上面的答案。干杯:)
 <div id="prev" onclick="myScroll.scrollToPage('prev', 0);return false"> stuff </div>