在聚合项目上转换dart2js时出错

在聚合项目上转换dart2js时出错,dart,dart-polymer,dart2js,Dart,Dart Polymer,Dart2js,不支持的操作:无法在反射中使用ownerName,因为@MirrorsUsed批注中未包含它 ownerName只是聚合物元素上已发布的属性。我知道有一些事情(在网络上,而不是在这里)像这样,但没有一个有一个可靠的答案 下面我也看到了: NoSuchMethodError:找不到方法:“符号(“标题”)” 有人有什么想法吗。我已经为此绞尽脑汁3个小时了,准备扔掉聚合物。虽然dartium很有趣,但如果它不能转换成JS,我看不出它有什么真正的用处 import'包装:polymer/polymer

不支持的操作:无法在反射中使用ownerName,因为@MirrorsUsed批注中未包含它

ownerName
只是聚合物元素上已发布的属性。我知道有一些事情(在网络上,而不是在这里)像这样,但没有一个有一个可靠的答案

下面我也看到了:

NoSuchMethodError:找不到方法:“符号(“标题”)”

有人有什么想法吗。我已经为此绞尽脑汁3个小时了,准备扔掉聚合物。虽然dartium很有趣,但如果它不能转换成JS,我看不出它有什么真正的用处

import'包装:polymer/polymer.dart';
导入“包:google_postendpoint_v1_api/postendpoint_v1_api_browser.dart”;
导入“包:google_postendpoint_v1_api/postendpoint_v1_api_client.dart”;
导入“dart:math”;
//导入“包:intl/intl.dart”;
/**
*一种聚合物柱状元件。
*/
@CustomTag('后元素')
类SoberSky扩展了聚合关系{
@公布的整数计数=0;
@已发布字符串ownerName=“Casey”;
@已发布的int ownerId=888;
@发布的int postId=333;
@发布的字符串内容=“哟呵呵,还有一瓶拉姆斯基!”;
@已发布字符串postContent=“这是post内容的一个示例”;
@已发布的int getOwnerId=333;
@已发布的CollectionResponse_评论列表评论;
@已发布的CollectionResponse_Post listPost;
@已发布的字符串列表注释HTML;
@已发表的文章;
@发布的布尔值是=假;
Postendpoint=新的Postendpoint();
var rng=新随机数();
var注释列表;
SoberSky.created():super.created(){
endpoint.rootUrl=”http://localhost:8888/“;//设置根URL
}
void getListComment([int tempPostId]){
if(tempPostId==null){
tempPostId=postId;
}
listComment(tempPostId).then((CollectionResponse\u Comment commentCollection){
this.listComment=commentCollection;
}).catchError((e)=>handleError(e));
}
void getPost(){
getPost(posted).then((Post-loadedMessage){
currentPost=加载的消息;
getListComment(currentPost.key);
}).catchError((e)=>handleError(e));
}
无效提交建议(){
int id=rng.nextInt(1000);
Comment Comment=new Comment.fromJson({});
comment.id=id;
comment.content=内容;
comment.postId=postId;
comment.ownerName=ownerName;
comment.ownerId=ownerId;
endpoint.insertComment(comment).then((comment savedComment)=>endpoint.getComment(id))。
然后((评论加载消息){
打印(loadedMessage.content);
getListComment(loadedMessage.postId);
}).catchError((e)=>handleError(e));
}
void submitPost(){
postId=rng.nextInt(1000);
Post Post=new Post.fromJson({});
post.key=posted;
post.ownerName=ownerName;
post.ownerId=ownerId;
post.title=后内容;
endpoint.insertPost(post).then((post savedPost)=>endpoint.getPost(postd))。
然后((后加载消息){
打印(加载的消息标题);
getPost();
getListComment(loadedMessage.key);
}).catchError((e)=>handleError(e));
}
无效句柄错误(错误e){
打印(“我们有一个错误:”);
打印(如toString());
}
@凌驾
附页(){
}
}
HTML聚合元素


进入帖子:
提交帖子
{{currentPost.ownerName} {{currentPost.title}}

这是postId:{{currentPost.key}

{{currentPost.uploadTime}

{{comment.ownerName} {{comment.content}

这是commentId:{{comment.id}

{{comment.formatDate}

输入注释: 提交评论

我还没有看到您的
不支持的操作
消息。也许是最近的变化。当类的属性仅由聚合表达式(HTML)引用时,
NoSuchMethodError
是常见的,因为树震动会删除所有未引用的代码,聚合表达式尚未对此进行计算。
@MirrorsUsed
注释有助于缩小这一差距

问题出在
Post
类中,因为它的属性仅在聚合表达式中引用


{{currentPost.ownerName}
{{currentPost.title}}

这是postId:{{currentPost.key}

{{currentPost.uploadTime}

要在
currentPost
中的属性更改时更新视图,应将
Post
类设置为

class Post使用可观察对象扩展对象{
@可观察的字符串所有者名称;
@可观察字符串标题;
...
}

如果您有像
@reflectable
@published
@observable
这样的注释,您不需要
@MirrorsUsed

,如果您提供聚合元件的代码,这将非常有用。不知道是否有人立即遇到了这个问题。似乎这是有点常见,但没有明确的解决方案…请添加您的HTML也。将得到聚合物元素在那里!谢谢我刚才看到:如果你覆盖
enteredView()
,你应该调用
super.enteredView()
,否则你会阻止元素正确插入DOM。谢谢你的回复!您能否链接到如何使用@MirrorsUsed注释的示例。这有点新,只是从聚合物教程中弄明白了一切。谢谢在页面顶部有一个例子。谢谢冈特的帮助。我要试试你建议的这些东西,明天再做。晚了,我的大脑被炸了。我真的想咆哮一下,说它在铬中工作得如此漂亮,然后