【问题标题】:Zepto.js: Tap event doesn't fireZepto.js:点击事件不会触发
【发布时间】:2013-05-19 21:55:10
【问题描述】:

嘿嘿,

我正在使用 Zepto (zeptojs.com)。这实际上是我的全部代码:

<html>
<head>
    <title>Test</title>
</head>
<body>

    <div>Tap me!</div>

<script type="text/javascript" src="zepto.min.js"></script>
<script>
$("div").on("tap", function() {
    alert("Tapped!");
})
</script>
</body>
</html>

在 Mac 上的 iPhone-Simulator 中运行它,当我点击 &lt;div&gt; 时没有任何反应。当我将tap 更改为touchend 时,alert 会出现。

我显然在这里做错了什么......但是什么?

【问题讨论】:

标签: javascript iphone zepto


【解决方案1】:

默认情况下,触摸模块不包含在 zepto dist 中。您可以链接该文件,也可以使用添加的触摸模块进行自己的构建。

只需从 github 克隆源代码并编辑 makefile。 target.built 部分中的模块列表。

...
target.build = ->
  cd __dirname
  mkdir '-p', 'dist'
  modules = (env['MODULES'] || 'zepto detect event ajax form fx touch').split(' ')
  module_files = ( "src/#{module}.js" for module in modules )
  ...

【讨论】:

    猜你喜欢
    • 2020-12-27
    • 2015-12-19
    • 1970-01-01
    • 1970-01-01
    • 2018-04-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多