本文介绍了无法运行简单的聚合物应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

好的..我已经在



在第二种情况下,尝试从 bower_components / webcomponentsjs / webcomponents.js 加载脚本 bower_components / polymer / polymer.js


OK.. I have configured Polymer Project as it is in This Video

Project structure is :

My custom element is :

<link rel="import" href="../bower_components/polymer/polymer.html">
<polymer-element name="hello-world" noscript>
<template>
    <h1>Hi From Custom Element</h1>
</template>
</polymer-element>

index.html is :

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Title of the document</title>
<script type="text/javascript" src="bower_components/polymer/polymer.js">
</script>
<link rel="import" href="elements/hello-world.html">
</head>
<body>
<hello-world></hello-world>
</body>
</html>

OK.. When I run this code without Server I get error :

 Imported resource from origin 'file://' has been blocked from loading by Cross-Origin Resource Sharing policy: Received an invalid response. Origin 'null' is therefore not allowed access.

and when I run the app on WAMP I get error :

Uncaught HierarchyRequestError: Failed to execute 'appendChild' on 'Node': Nodes of type 'HTML' may not be inserted inside nodes of type '#document'. 
 Uncaught TypeError: object is not a function

in polymer.js any help in this case?

解决方案

Due to the nature of polymer you can't just run things with the file: URI. See https://www.polymer-project.org/docs/start/reusableelements.html

In the second case try loading your script from bower_components/webcomponentsjs/webcomponents.js instead of bower_components/polymer/polymer.js.

这篇关于无法运行简单的聚合物应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-28 19:16