javascript 未捕获的类型错误 $(...).swipe 不是函数

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/31771227/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-28 14:20:51  来源:igfitidea点击:

uncaught typeerror $(...).swipe is not a function

javascriptjqueryblogger

提问by user3772967

Iam trying to make a swipeable menu in blogger and this is my code :

我正在尝试在博主中制作一个可滑动的菜单,这是我的代码:

<script type="text/javascript" src="http://code.jquery.com/jquery-1.9.1.js"></script>
<script type="text/javascript" src="https://www.googledrive.com/host/0B2Iusn9ixPQ2cFFldHoweXRsWms"></script>


<script type="text/javascript">
      $(window).load(function(){
        $("[data-toggle]").click(function() {
          var toggle_el = $(this).data("toggle");
          $(toggle_el).toggleClass("open-sidebar");
        });
         $(".swipe-area").swipe({
              swipeStatus:function(event, phase, direction, distance, duration, fingers)
                  {
                      if (phase=="move" &amp;&amp; direction =="right") {
                           $(".container").addClass("open-sidebar");
                           return false;
                      }
                      if (phase=="move" &amp;&amp; direction =="left") {
                           $(".container").removeClass("open-sidebar");
                           return false;
                      }
                  }
          }); 
      });

    </script>

and Iam getting this error at " $(".swipe-area").swipe({" : uncaught typeerror $(...).swipe is not a function

我在“ $(".swipe-area").swipe({" : uncaught typeerror $(...).swipe is not a function

PLease Help, Thanks

请帮忙,谢谢

采纳答案by shreeramk

Try this

试试这个

<html>
<head>

<script src="http://code.jquery.com/jquery-1.11.3.min.js"></script>
<script src="http://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.js"></script>
<script>
$(document).on("pagecreate","#pageone",function(){
  $("p").on("swipe",function(){
    $(this).hide();
  });                       
});
</script>
</head>
<body>

<div data-role="page" id="pageone">
  <div data-role="main" class="ui-content">
    <p>If you swipe me, I will disappear.</p>
    <p>Swipe me away!</p>
    <p>Swipe me too!</p>
  </div>
</div> 

</body>
</html>

Update- Unexpected token

更新- 意外令牌

There is a syntax errorin your code in below line

您的代码在下面的行中存在语法错误

swipeStatus:function(event, phase, direction, distance, duration, fingers)

Correct syntax - In below way, you can define swipeStatusa function

正确的语法 - 在下面的方式中,您可以定义swipeStatus一个函数

var swipeStatus  = function(event, phase, direction, distance, duration, fingers)

回答by madhukar

Try this....

试试这个....

<script>
$(document).on("pagecreate","#pageone",function(){
  $("p").on("swipe",function(){
    $(this).hide();
  });                       
});
</script>`enter code here`

回答by Narendra Reddy

Ans:

答:

load all jquery dependencies first , then load touchSwipe library

首先加载所有 jquery 依赖项,然后加载 touchSwipe 库