简体   繁体   English

如何在Ember.js应用程序中显示列表组件?

[英]How can I display a list components in my Ember.js application?

My Ember.js has many components that the end-user can use to compose a page. 我的Ember.js具有许多组件,最终用户可以使用它们来构成页面。 How can I display a dynamic list of the components that exist in my Ember Application? 如何显示Ember应用程序中存在的组件的动态列表?

I imagine the registered components is somewhere in the Ember.Application object, but I'm having a hard time finding something I can use. 我想注册的组件位于Ember.Application对象中的某个位置,但是我很难找到可以使用的东西。

# in the route
import computed from 'ember-computed';
import getOwner from 'ember-owner/get';

...
{
  components: computed(function () {
    return getOwner(this).lookup('container-debug-adapter:main')
      .catalogEntriesByType('component')
      .filter(componentName => componentName.includes('composables'))
  })
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM