我可以为Ember组件提供模板名称吗?

vin*_*206 5 javascript ember.js

我想要这样的事情:

App.SimplyHelloComponent = Em.Component.extend({
                       classNames: ['bold', 'italic', 'blue']

                       templateName:'my-temp'
                });
Run Code Online (Sandbox Code Playgroud)

小智 0

这是可行的,但'components/'会作为前缀添加到templateName提供的查找中。

因此,如果您想使用该名称'my-temp',请使用

<script type="text/x-handlebars" data-template-name="components/my-temp">
...
</script>
Run Code Online (Sandbox Code Playgroud)

对于内联模板,或者让构建工具my-tempcomponents/模板子目录预编译模板。