可以'找不到可变聚合物

Can't find variable Polymer

本文关键字:聚合物 找不到 可以      更新时间:2023-09-26

使用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>

问题是,当运行时,我得到错误"找不到变量聚合物"?有人知道为什么吗?

如果这是所有的代码,那么就缺少了应该在模块之前的链接元素。

<link rel="import" href="../polymer/polymer.html">
<dom-module id="template-me">
    <template>
      ...

仔细检查您的聚合物导入代码和路径。以下是使用repo中的polymer.htmltemplate-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>