version="0.8">
const testComponent = require('discourse/app/raw-views/list/posts-count-column').default;
testComponent.reopen({
user: function() {
return Discourse.User.current()
}.property()
});
</script>
我尝试使用 repoen() 来修改 posts-count-column 组件以传递 currentUser 值,如下面的示例所示,但遇到了错误。我认为也许只有特定类型的组件支持此方法?
我找到了另一种方法,通过从上到下覆盖来将 currentUser 值传递到嵌套的 hbr 中,通过添加 {{raw "list/posts-count-column" topic=topic tagName="div" **user=user**}} 来插入值
data-template-name='mobile/list/topic-list-item.raw’>
data-template-name='list/post-count-or-badges.hbr'
data-template-name="list/posts-count-column.hbr"
emberjs 是否有像 vue 那样的 provide/inject 函数来将值传递到嵌套模板?我搜索了一下,但没有找到太多信息。对此有什么建议吗?