gpt4 book ai didi

ember.js - {{content-for 'head'}} Ember-cli

转载 作者:行者123 更新时间:2023-12-03 08:48:15 25 4
gpt4 key购买 nike

在过去的1个月里,我一直在使用Yeoman ember generator,现在,我想尝试一下ember-cli。

我运行发电机并启动应用程序,一切正常。

ember new my-new-app
ember server

但我想知道如何
{{content-for 'head'}}

在app / index.html中工作吗?

当查看 http://www.ember-cli.com/#tutorials的其他示例时,没有人使用这个特定的帮助程序吗?是因为他们使用的是ember-cli的旧版本吗?他们为什么不使用此内容帮助器?

我很确定ember.js缺省没有此内容(用于帮助程序),所以我猜ember-cli在某个地方写了它?它在哪里,做什么用的?

另外,当我检查my-new-app页面的元素时,“Welcome to Ember.js”的div标 checkout 现在body标签而不是head标签上了吗?那怎么可能? {{mind-blown}}

(在app / index.html中,{{content-for'head'}}被放置在head标签内)

最佳答案

最近已将其添加到基于this discussion的ember-cli中。

这是commit的相关代码:

EmberApp.prototype.contentFor = function(config, match, type) {
var content = [];

if (type === 'head') {
content.push(calculateBaseTag(config));

content.push('<meta name="' + config.modulePrefix + '/config/environment" ' +
'content="' + escape(JSON.stringify(config)) + '">');
}

content = this.project.addons.reduce(function(content, addon) {
if (addon.contentFor) {
return content.concat(addon.contentFor(type, config));
}

return content;
}, content);

return content.join('\n');
};

关于ember.js - {{content-for 'head'}} Ember-cli,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26210367/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com