Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
你怎么知道你的 Ember 视图的元素已经插入到文档中?
我目前的方法是:
if (this.$().length) { // ... }
另一种解决方案是检查视图字典。如果你有这样的看法:
var helloView = Em.View.create({ elementId: 'hello' });
你可以做:
var myView = Ember.View.views.hello; // Check if it is in the DOM myView.get('state') === "inDOM"; // Check if it is visible myView.get('isVisible');