Polymer 2.0 errors
I have worked with Polymer 1.x for a while and I want to start a project from scratch with Polymer 2.0 but I get many errors. I am building a PWA as I did before, therefor I included a service worker and a manifest.json file. The errors I get are, I think, most of incompatibility between versions since they claim some classes not defined or undefined "window" object (like in the second error)
For versions I followed this guide (point: Upgrade an existing project)
https://www.polymer-project.org/2.0/docs/about_20#polymer-1-compatibility-layer
First error:
platinum-sw-register.html:111
Uncaught ReferenceError: HTMLImports is not defined at platinum-sw-register.html:111
and
Uncaught TypeError: Cannot read property 'nativeMethods' of undefined
at pa (style-util.js:243)
at p.u (style-properties.js:499)
at k.T (scoping-shim.js:299)
at k.styleElement (scoping-shim.js:243)
at Object.styleElement (scoping-shim.js:52)
at HTMLElement.connectedCallback (element-mixin.html:636)
at HTMLElement.connectedCallback (legacy-element-mixin.html:81)
I have the following index.html
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, minimum-scale=1.0, initial-scale=1, user-scalable=yes">
<title>AppTest</title>
<link rel="import" href="bower_components/app-layout/app-layout.html"/>
<link rel="import" href="bower_components/platinum-sw/platinum-sw-elements.html"/>
<link rel="manifest" href="manifest.json"/>
<script src="bower_components/webcomponentsjs/webcomponents-lite.js"></script>
<!-- <script src="bower_components/web-animations-js/web-animations.min.js" async></script> -->
<link rel="import" href="bower_components/app-layout/app-drawer/app-drawer.html">
<link rel="import" href="bower_components/app-layout/app-header/app-header.html">
<link rel="import" href="bower_components/app-layout/app-toolbar/app-toolbar.html">
</head>
<body>
<platinum-sw-register
auto-register
skip-waiting
clients-claim
reload-on-install
href="sw-import.js">
<platinum-sw-cache
default-cache-strategy="networkFirst">
</platinum-sw-cache>
</platinum-sw-register>
<app-header reveals>
<app-toolbar>
<div main-title>My app</div>
</app-toolbar>
</app-header>
<app-drawer id="drawer" swipe-open></app-drawer>
</body>
<script>
</script>
</html>
and my bower.json
{
"name": "polymer-2-carousel",
"private": true,
"dependencies": {
"polymer": "Polymer/polymer#^2.0.0-rc.3",
"platinum-sw": "PolymerElements/platinum-sw#2.0-preview",
"app-layout": "PolymerElements/app-layout#2.0-preview"
}
}
As you can see the application is a skeleton very simple (just a test to start with) so there should not be much to get wrong or to investigate to find the cause of the error but I do not understand what is the problem and how to fix it. Any help would be appreciate.
I found this problem too, so I have to change these lines below in bower-components/platinum-sw/platinum-sw-register.html
file:
value: document._currentScript ? document._currentScript.baseURI :
(HTMLImports.importForElement ? HTMLImports.importForElement(document.currentScript).baseURI :
(document.currentScript ? document.currentScript.baseURI : './'))
To:
value: document._currentScript ? document._currentScript.baseURI :
(document.currentScript ? document.currentScript.baseURI : './')
I hope that helps.
链接地址: http://www.djcxy.com/p/5330.html上一篇: 聚合物2.0调用函数
下一篇: 聚合物2.0错误