1
在聚合物的演示頁面上,一切正常,在我的頁面上,它已損壞。聚合物/ platform.js polyfill addEventListener在iOS設備中爲null
在這一行哽咽道:
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">
值得一提,適用於Firefox和Chrome。 – 2014-09-04 05:54:40