有人用过hammer.js 这个插件么,能否提供一个demo?按照官网上的demo就没有成功过,总是报错caught TypeError: undefined is not a function ,自己写的demo如下,不知道有什么地方出错了,Thx
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="user-scalable=no, width=device-width, initial-scale=1, maximum-scale=1">
<script type="text/javascript" src="/js/hammer.js"></script>
<style>
.hitarea{width:300px;height:300px;background-color:red;}
</style>
</head>
<body>
<p id="hitarea" class="hitarea"></p>
<script>
var container= document.getElementById("hitarea");
var hammertime = new Hammer(container, {
preventDefault: true,
gesture: true
});
hammertime.on("swipeleft", function(){
alert("swipeleft");
});
hammertime.on("swiperight", function(){
alert("swiperight");
});
</script>
</body>
</html>
这是一个手势相关的库,官网地址:http://hammerjs.github.io/
我下载了官网的压缩脚本,运行了您的程序,没报错,程序也能按照期望能运行,运行截图如下:
我运行了下,没发现有错误,可以正常运行。
你好,这个问题解决没?
<script>标签下面加入下面的东西,后面代码都写在里面
window.addEventListener('load',function(){
});
我也遇到同样的问题,不知道什么原因