2014-06-18 41 views
0

由于某些原因,Polymer自定义元素的内部(:主机)样式未加载。我使用的是来自pub的实际fancy_button组件(https://pub.dartlang.org/packages/fancy_button)。为什么我的聚合物定制元素中的样式不被识别?

hello_world.html

<head> 
    <link rel="import" href="packages/polymer/polymer.html"> 
    <link rel="import" href="packages/fancy_button/fancy_button.html"> 
    <link rel="import" href="../lib/components/first-component/first-component.html"> 
</head> 

<body> 
<button is="fancy-button">Wooot!</button> 
<script type="application/dart">export 'package:polymer/init.dart';</script> 
</body> 

fancy_button.html:

<link href='http://fonts.googleapis.com/css?family=Tangerine' rel='stylesheet' type='text/css'> 

<polymer-element name="fancy-button" extends="button"> 
    <template> 
    <style> 
     :host { 
     background: linear-gradient(to bottom, #ff5db1 0%,#ef017c 100%); 
     box-shadow: 10px 10px 5px #888888; 
     border-radius: 5px; 
     font-size: 2em; 
     border: 0; 
     font-family: 'Tangerine', cursive; 
     padding: 30px; 
     } 

     :host(:hover) { 
     cursor: pointer; 
     } 

     :host(:active) { 
     font-size: 3em; 
     } 
    </style> 
    <content></content> 
    </template> 
    <script type="application/dart" src="fancy_button.dart"></script> 
</polymer-element> 
+0

看起来不错。 Dartium开发人员工具是否显示错误输出? –

回答

1

我想你的代码和它的作品对我来说(我得到一个巨大的粉色 '活泉' 按钮,这增加了它的大小当点击)

当我评论这条线

<!--<link rel="import" href="../lib/components/first-component/first-component.html">--> 

我也不得不加

transformers: 
- polymer: 
    entry_points: 
    - web/hello_world.html 

到pubspec.yaml(dev的通道飞镖版本1.5.0边缘)

这可能是为什么在这里而不是为你工作的原因
但我看不到在Dart 1.4中尚未支持的CSS中的任何内容。

我也保持在聚合物的依赖性(0.10.1 + 1)

+0

嗨Günter。我删除了该行,仍然没有去。这里是我的代码:https://github.com/DaveNotik/woven_sandbox –

+0

仍然在这里工作。 –

+0

您是否看到应用的样式?是的,我有Dart 1.4.3。我已经添加了变形金刚。我只是意识到,它在'pub build'/build(在Chrome中)之后工作,而不是在常规/ web中(在Dartium中)。有什么理由呢?它是否真的需要建立它的工作? –