我正在尝试使用 CustomComponent 可选地替换帖子的简短操作描述。
但是,帖子未正确传递给值转换器。
@cached
get CustomComponent() {
return applyValueTransformer("post-small-action-custom-component", null, {
actionCode: this.code,
post: this.post,
});
}
我的调试代码
api.registerValueTransformer(
"post-small-action-custom-component",
(arg) => {
console.log(arg);
}
);
输出:
context: Object { actionCode: "bid", post: undefined }
测试 不检查参数,因此这种情况被忽略了。
我猜 post 参数应该是 this.args.post 而不是 this.post。
我一直在尝试一种变通方法,即无条件地添加组件并让它自己检查该做什么,但不幸的是,参数似乎也没有正确传递,因此变通方法和正常实现在这里都会失败:
<this.CustomComponent
@code={{this.code}}
@post={{this.post}}
@createdAt={{this.createdAt}}
@path={{this.path}}
@username={{this.username}}
/>
PostSmallAction 中有 code、createdAt 和 path 的 getter,但是(再次)this.post 不存在,并且 username() 似乎也有一个错误(this.args.post 中没有 action_code_who?),因此这些属性保持为空。
我找不到现有的“真实世界”实现。我真的是第一个使用这个的人吗?![]()