好的..我已在Polymer Project
中配置了This Video项目结构是:
我的自定义元素是:
<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是:
<!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>
好的..当我在没有服务器的情况下运行此代码时,我收到错误:
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.
当我在WAMP上运行应用程序时,我收到错误:
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
在 polymer.js 中在这种情况下的任何帮助?
答案 0 :(得分:3)
由于聚合物的性质,您无法使用file:
URI运行。见https://www.polymer-project.org/docs/start/reusableelements.html
在第二种情况下,请尝试从bower_components/webcomponentsjs/webcomponents.js
而不是bower_components/polymer/polymer.js
加载脚本。