[英]Can't find variable Polymer
Using Polymer 1.x I've tried to create a dom module like following: 使用Polymer 1.x,我尝试创建一个dom模块,如下所示:
<dom-module id="template-me">
<template>
<!-- local DOM styles -->
<style>
div { color: red }
</style>
<div>This is local DOM</div>
</template>
<script>
Polymer({is: "template-me"});
</script>
</dom-module>
The problem is that when running I get the error "Can't find variable Polymer"? 问题是运行时出现错误“找不到变量Polymer”? Does anyone knows why? 有谁知道为什么?
If that is all the code, you are missing the link element that should be before the module. 如果仅此而已,那么您将缺少应该在模块之前的link元素。
<link rel="import" href="../polymer/polymer.html">
<dom-module id="template-me">
<template>
...
Double check your polymer import code and the path. 仔细检查您的聚合物导入代码和路径。 Here is a working demo of template-me
using polymer.html
from repo. 这是使用来自repo的polymer.html
的template-me
的工作演示。
<html> <head> <title>Template me</title> <link rel="import" href="https://cdn.rawgit.com/download/polymer-cdn/1.0.1/lib/polymer/polymer.html"> </head> <body class="fullbleed"> <template-me></template-me> <dom-module id="template-me"> <template> <style> div { color: red } </style> <div>This is local DOM</div> </template> <script> Polymer({ is : "template-me" }); </script> </dom-module> </body> </html>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.