为什么聚合物元素<纸张按钮>无法渲染</paper-button>

时间:2015-04-04 06:46:46

标签: dart dart-polymer

为什么<paper-button>无法渲染?其他所有工作都会生效,并会显示带有id=button1的按钮。 我试图使用不同的路径:

<link rel="import" href="../../packages/paper_elements/paper_button.html"> 

但它仍然无效。我使用dart 1.91聚合物聚合物:0.16.0 + 7 paper_elements:0.6.2 + 3

//***************INDEX.HTML FILE 
<!DOCTYPE html>

<html>
<head>
<meta charset="utf-8">
<link rel="stylesheet" href="styles/main.css">
<link rel="import" href="packages/polymer/polymer.html">
<link rel="import" href="packages/paper_elements/paper_button.html">
<script src="packages/browser/dart.js"></script>
<script type="application/dart" src="main.dart"></script>

<title>Test my polymetr test 152</title>
</head>

<body unresolved>
  <h1 id="output">the output div</h1>
  <label id="hello">hello vr y31</label>
  <button id="button1">Enter button</button>
  <paper-button></paper-button>
</body>
</html>
//***************MAIN.DART FILE 
// Copyright (c) 2015, <your name>. All rights reserved. Use of this source code
// is governed by a BSD-style license that can be found in the LICENSE file.

import 'dart:html';
import "dart:async";
import 'package:polymer/polymer.dart';

void main() {
   void realMain() {
    Element abc=querySelector("#output");
    abc.text="Up and running";
  };

  initPolymer().then((zone) => zone.run(realMain));
  Element button1=querySelector("#button1");
  button1.onClick.listen(buttonClick);
}

void buttonClick(Event e){
  (e.target as ButtonElement).text='Clicked button';
}
//***************PUPSPEC.YAML file
name: Atests
version: 0.0.1
description: An absolute bare-bones web app.
environment:
  sdk: '>=1.0.0 <2.0.0'
dependencies:
  browser: any
  paper_elements: 0.6.2+3
  polymer: '>=0.16.0+7 <0.17.0'
transformers:
- polymer:
    entry_points: web/index.html

1 个答案:

答案 0 :(得分:0)

如果您添加一些文字({<paper-button>xxx</paper-button>),您会看到该按钮在那里,它就是不可见。另外,当您在Chrome开发工具中调查DOM时,您会看到{{1} }元素在那里并且还有一个影子DOM(如果你在dev-tools设置中激活以显示影子DOM),这表明元素已正确初始化。 即使没有添加文本,您也可以单击按钮(在[Enter按钮]的右侧,您将看到涟漪效应。