如何使用Ember CLI在两个组件之间共享模板? [英] How can I share a template between two components using Ember CLI?

查看:108
本文介绍了如何使用Ember CLI在两个组件之间共享模板?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有两个组件: SpecialButtonComponent SpecialButtonDerivativeComponent



SpecialButton 组件自动使用在 /app/templates/components/special-button.hbs上找到的模板



我想要 SpecialButtonDerivativeComponent 使用相同的模板,但到目前为止我没有运气尝试要使用这种技术:

  // app / components / special-button-derivative.js 
import SpecialButtonComponent from './special-button';

export defaultButtonComponent.extend({
templateName:'components / special-button'
});

我还试过使用 layoutName templateName ,但还是没有运气。任何想法?

解决方案

组件没有 templateName p>

我将尝试将 layout 设置为null,然后指定一个 layoutName


I have two components: SpecialButtonComponent and SpecialButtonDerivativeComponent.

The SpecialButton component automatically uses the template found at /app/templates/components/special-button.hbs.

I would like for SpecialButtonDerivativeComponent to use the same template, but so far I'm having no luck trying to go with this technique:

// app/components/special-button-derivative.js
import SpecialButtonComponent from './special-button';

export default SpecialButtonComponent.extend({
  templateName: 'components/special-button'
});

I've also tried using layoutName instead of templateName, but still no luck. Any ideas?

解决方案

Components do not have a templateName.

I would try to set layout to null and then specify a layoutName.

这篇关于如何使用Ember CLI在两个组件之间共享模板?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆