我使用ember-cli随机开始在我的应用上收到此错误Uncaught Error: Assertion Failed: Attempted to register a view with an id already in use: name
。
我只有两条路线
Router.map(function() {
this.route('buy');
this.route('rent');
});
没有控制器,我的索引路由会将我重定向到buy
redirect: function() {
this.transitionTo('buy');
}
我的rent
路由也会呈现buy
模板
renderTemplate: function() {
this.render('buy');
}
我没有rent
或index
模板。
我不知道这个错误来自哪里。
答案 0 :(得分:9)
我弄明白为什么,原来我的模板上有两个具有相同ID的输入,
{{ input name="name" id="name" placeholder="Full Name" class="full-width" }}
两次在不同的地方。如果错误消息可以提供更多信息,并为您提供实际代码的一行,而不是仅显示throw new EmberError("Assertion Failed: " + desc);
文件中的vendor.js
行,那将非常有用。
答案 1 :(得分:3)
我遇到了同样的问题,最后我只是在Chrome Elements标签中搜索了所有已识别为重复的ID的元素。事实证明这是查找重复ID来源的好方法。