내 샘플 앱이 Chrome과 Firefox에서 작동하기를 원했기 때문에 나는 https://www.webcomponents.org/polyfills/에서 설명한대로 웹 구성 요소를 polyfill하려고합니다. 그러나 나는 받고있다 ReferenceError : customElements가 정의되지 않았다. Firefox에서 오류. 아래의 코드를 index.html에서 참조하십시오.Webcomponents Polyfill not working
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="robots" content="index, follow">
<meta name="viewport" content="width=device-width, initial-scale=1.0, shrink-to-fit=no">
<meta http-equiv="x-ua-compatible" content="ie=edge">
<title>Sample</title>
<link rel="stylesheet" href="css/site.css">
<!-- Components -->
<link rel="import" href="components/global/site-navigation.html">
</head>
<body>
<script>
(function() {
if ('registerElement' in document
&& 'import' in document.createElement('link')
&& 'content' in document.createElement('template')) {
// platform is good!
} else {
// polyfill the platform!
var e = document.createElement('script');
e.src = 'js/webcomponents.js';
document.body.appendChild(e);
}
})();
</script>
<site-navigation></site-navigation>
</body>
</html>
무엇이 누락 되었습니까?
PS : 모든 당신은 webcomponentsjs 구현 polyfill, 이전 버전을 사용하는
나는 당신이 당신에게 구성 요소를 포함 _before_ 당신의 polyfill 로더 코드를 배치 할 필요가 있다고 생각합니다. – Intervalia
어떤 버전의 webcomponents polyfill을 사용합니까? – Supersharp
나는 이것을 다음과 같이 볼 수있다 : 10 of webcomponents.js // @version 0.7.24 –