javascript - iOS 设备中的 Polymer/platform.js polyfill addEventListener null

标签 javascript ios iphone polymer polyfills

在 Polymer 的演示页面上,一切正常,在我的页面上,它坏了。

在这条线上窒息:

      var isSafari = nav.userAgent.match('Safari') && !nav.userAgent.match('Chrome');
      if (isSafari) {
        // v -- choking here --  v
        document.body.addEventListener('touchstart', function(){});
      }
    }
  }
  dispatcher.register(document, true);
})(window.PolymerGestures);

我在控制台中收到以下错误:

Uncaught TypeError: Cannot read property 'addEventListener' of null

看起来 body 为空,调试器确认。

这里是我包含 platform.js 的地方:

<!DOCTYPE html>
<html class="no-js">
  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>{{ page.title }}</title>
    <meta name="description" content="">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="apple-mobile-web-app-capable" content="yes">

    <script src="/components/platform/platform.js"></script>

    <link rel="import" href="/components/paper-tabs/paper-tabs.html">

最佳答案

这是 master 中修复的错误:https://github.com/Polymer/polymer-gestures/pull/47

请在 github 上提交任何其他类似的错误。

关于javascript - iOS 设备中的 Polymer/platform.js polyfill addEventListener null,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25658122/

相关文章:

iphone - 图像质量较低不像在相册中显示

javascript 是同步编程语言,不是吗?

android - 如何将对我的 REST API 的访问限制为仅授权客户端?

iphone - 为什么我会看到有关 NSAutoreleasePool 不可用的警告消息?

ios - 证书已过期或已被吊销

ios - 在 iOS 9 中通过 WhatsApp 共享字符串 + 图像

iphone - 如何一次为所有元素设置 VoiceOver 辅助语言?

javascript - 元素属性更改后对数组进行排序 - Knockout JS

javascript - 如何在AngularJs中同时绑定(bind)单选按钮和复选框?

javascript - 对多个时间范围进行排序