【发布时间】:2014-11-20 04:52:21
【问题描述】:
当我将参数传递给 Polymer 元素时,核心样式 ref 没有得到解析。
这是子代码:
<link rel="import" href="packages/polymer/polymer.html">
<link rel="import" href="packages/core_elements/core_style.html">
<core-style id="s1" unresolved> div { background: yellow; } </core-style>
<core-style id="s2" unresolved> div { background: pink; } </core-style>
<polymer-element name='test-cell' attributes='s t' noscript>
<template>
<core-style ref="{{s}}"></core-style>
<div>{{t}}</div>
</template>
</polymer-element>
如您所见,有两种核心样式。
这是父代码。它接受一个 List 并使用文本和样式引用实例化“test-cell”。
<polymer-element name='test-rows'>
<template>
<template repeat='{{ v in x }}'>
<test-cell s={{v.s}} t={{v.t}}></test-cell>
</template>
</template>
</polymer-element>
在这个简单的例子中,Dart 代码是内联的。这里是:
<script type='application/dart'>
import 'package:polymer/polymer.dart';
//======================================
class Info {
String s, t;
Info(this.s, this.t) {}
}
//======================================
@CustomTag('test-rows')
class TestRows extends PolymerElement {
@observable List<Info> x = toObservable([]);
//-----------------------------------
TestRows.created() : super.created() {
x.add(toObservable(new Info('s1', 'first' )));
x.add(toObservable(new Info('s2', 'second')));
}
}
</script>
在生成的 HTML 中,文本通过 OK,但核心样式实例都有
ref="{{s}}"
并且不应用样式。我可以通过一些替代注释强制解析样式参考参数吗?它本质上是一个 final/const。
【问题讨论】:
标签: dart polymer dart-polymer