2

我正在尝试制作嵌套的聚合物元素。编辑器没有显示错误或警告。

组件one.html

<link rel="import" href="componenttwo.html">

<polymer-element name="component-one" noscript>
   <template>
      <h1>Parent element</h1>
      <component-two></component-two>
   </template>
</polymer-element>

组件二.html

<polymer-element name="component-two" noscript>
   <template>
    <h2>Nested element</h2>   
   </template>
</polymer-element>

测试组件.html

<html>
   <head>
      <link rel="import" href="componentone.html">
      <script src="packages/polymer/boot.js"></script> 
      <script src="packages/browser/interop.js"></script>
   </head>

   <body>   
      <component-one></component-one>

      <script type="application/dart" src="testcomponents.dart"></script>
   </body>
</html>

当我运行 testcomponents.html 时,浏览器中没有出现任何内容,但在编辑器控制台中出现错误

Invalid CSS property name: -webkit-touch-callout
Exception: Stack Overflow
   runMicrotask (package:observe/src/microtask.dart:63:45)
   initPolymer (package:polymer/src/loader.dart:32:15)
   main (http://127.0.0.1:3030/jukudart2/web/testcomponents.html:5:22)
   registerCustomElement (package:custom_element/custom_element.dart:62:25)
   initPolymer.<anonymous closure> (package:polymer/src/loader.dart:39:26)
   runMicrotask.<anonymous closure> (package:observe/src/microtask.dart:65:16)
4

2 回答 2

4

我试过你的例子,得到了同样的错误。

当我为两个组件添加一个 dart 文件并指定 CustomTag 注释时,它起作用了:

组件one.html

<link rel="import" href="componenttwo.html">

<polymer-element name="component-one">
   <template>
      <h1>Parent element</h1>
      <component-two></component-two>
   </template>

   <script type="application/dart" src="componentone.dart"></script>
</polymer-element>

组件one.dart

import 'package:polymer/polymer.dart';

@CustomTag("component-one")
class ComponentOne extends PolymerElement {  
}

组件二.html

<polymer-element name="component-two">
   <template>
    <h2>Nested element</h2>
   </template>
   <script type="application/dart" src="componenttwo.dart"></script>
</polymer-element>

组件二.dart

import 'package:polymer/polymer.dart';

@CustomTag("component-two")
class ComponentTwo extends PolymerElement {
}
于 2013-10-14T21:07:53.490 回答
0

在 componentone.html 中,尝试将链接放在聚合物元素标签内,但在模板标签之前。(对不起,我的简短,在手机上)

于 2013-10-14T17:35:34.287 回答