看来我曾经工作的Polymer Dart自定义元素现在停止了射击。 Dartium在localhost中显示h1标签,但不显示我的自定义元素。
我得到的唯一Dart编辑器错误/警告是:
"(from html5lib) Unexpected start tag (link). Expected DOCTYPE. See http://goo.gl/5HPeuP#polymer_40 for details."
每条
都会显示此警告消息 <link rel="import" href="packages/polymer/polymer.html">
但最好的我可以看到这是一个已知问题,不应妨碍应用程序的执行。
我迄今为止的故障排除工作包括: - 从命令行运行pub cache cache - 手动删除包缓存目录并再次运行pub。 - 下载并运行polymer-and-dart-codelab-master.zip(我得到相同的行为)
如何诊断此问题?
Pubspec.yaml内容:
name: mpower
description: Sample app built with the polymer.dart package
environment:
sdk: '>=1.2.0 <2.0.0'
dependencies:
polymer: '>=0.15.1 <0.16.0'
dev_dependencies:
unittest: '>=0.10.0 <0.11.0'
transformers:
- polymer:
entry_points:
- web/index.html
Index.html内容:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Mosaic mPower</title>
<link rel="import" href="est_list.html">
<link rel="stylesheet" href="app.css">
</head>
<body>
<h1>Mosaic mPower</h1>
<est-list></est-list>
<script type="application/dart">export 'package:polymer/init.dart';</script>
</body>
</html>
EST-list.html
<link rel="import" href="packages/polymer/polymer.html">
<link rel="import" href="est_form.html">
<link rel="import" href="est_element.html">
<polymer-element name="est-list">
<template>
<style>
select {
margin-bottom: 30px;
display: inline;
padding: 6px 12px;
font-size: 14px;
line-height: 1.42857143;
color: #555;
background-color: #fff;
background-image: none;
border: 1px solid #ccc;
border-radius: 2px;
-webkit-box-shadow: inset 0 1px 1px rgba(0,0,0,.075);
box-shadow: inset 0 1px 1px rgba(0,0,0,.075);
-webkit-transition: border-color ease-in-out .15s,box-shadow ease-in-out .15s;
transition: border-color ease-in-out .15s,box-shadow ease-in-out .15s;
}
</style>
<div>
<label>Filter: </label>
<select value="{{filterValue}}" on-change="{{filter}}">
<option template repeat="{{filter in filters}}">
{{filter}}
</option>
</select>
</div>
<div on-estvalidated="{{addEst}}"
on-formnotneeded="{{resetForm}}">
<est-form est="{{newEst}}"></est-form>
</div>
<div on-deleteest="{{deleteEst}}"
on-levelchanged="{{filter}}">
<template repeat="{{est in filteredEsts}}">
<est-element est="{{est}}"></est-element>
</template>
</div>
</template>
<script type="application/dart" src="est_list.dart"></script>
EST-list.dart
import 'package:polymer/polymer.dart';
import 'model.dart' show Est;
import 'dart:html' show Event, Node;
/*
* Class to represent a collectionon-est of Est objects.
*/
@CustomTag('est-list')
class EstList extends PolymerElement {
static const ALL = "all";
/*
* Field for a new Est object.
*/
@observable Est newEst = new Est();
/*
* Collection of ests. The source of truth for all ests in this app.
*/
@observable List<Est> ests = toObservable([]);
/*
* Sets the new est form to default to the intermediate level.
*/
String get defaultCustomer => Est.CUSTOMERS[0];
/*
* List of filter values. Includes the levels defined in the model, as well
* as a filter to return all ests.
*/
final List<String> filters = [ALL]..addAll(Est.CUSTOMERS);
/*
* String that stores the value used to filter ests.
*/
@observable String filterValue = ALL;
/*
* The list of filtered ests.
*/
@observable List<Est> filteredEsts = toObservable([]);
/*
* Named constructor. Sets initial value of filtered ests and sets
* the new est's customer to the default.
*/
EstList.created() : super.created() {
filteredEsts = ests;
newEst.customer = defaultCustomer;
}
/*
* Replaces the existing new Est, causing the new est form to reset.
*/
resetForm() {
newEst = new Est();
newEst.customer = defaultCustomer;
}
/*
* Adds a est to the ests list and resets the new est form. This
* triggers estsChanged().
*/
addEst(Event e, var detail, Node sender) {
e.preventDefault();
ests.add(detail['est']);
resetForm();
}
/*
* Removes a est from the ests list. This triggers estsChanged().
*/
deleteEst(Event e, var detail, Node sender) {
var est = detail['est'];
ests.remove(est);
}
/*
* Calculates the ests to display when using a filter.
*/
filter() {
if (filterValue == ALL) {
filteredEsts = ests;
return;
}
filteredEsts = ests.where((est) {
return est.customer == filterValue;
}).toList();
}
/*
* Refreshes the filtered ests list every time the ests list changes.
*/
estsChanged() {
filter();
}
}
答案 0 :(得分:0)
如评论中所述, 这是由过期的Dartium造成的。
可悲的是,它没有显示消息来讲述它。 明确这个未解决的问题http://dartbug.com/18560以获取更新。