2014-06-18 79 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中)。有什麼理由呢?它是否真的需要建立它的工作? –