使用 ember 方法分配組件屬性時傳遞條件字符串的正確方法是什么concat()?考慮以下{{#my-compontent class=(concat (dasherize model.name)"-row")}} {{model.name}}{{/my-component}}我想要做的是--disabled根據model.disabled屬性有條件地添加后綴。我嘗試過的:{{#my-compontent class=(concat (dasherize model.name)"-row{{if model.disabled '--disabled'}}")}} {{model.name}}{{/my-component}}導致:<div class="component-name-row{{if model.disabled '--disabled}}"> Component name</div>我嘗試的另一件事是使用ternary助手,基于這個答案:{{#my-compontent class=(concat (dasherize model.name)"-row"(ternary model.disabled '--disabled' ''))}} {{model.name}}{{/my-component}}但它崩潰了:斷言失敗:找不到名為“ternary”的助手有什么辦法可以做到這一點嗎?如果不是,我如何使用不同的方法達到相同的效果?
如何使用 concat 將條件字符串傳遞給 ember 組件屬性?
慕神8447489
2023-12-14 14:14:01