嗨我试图根据布尔值动态更改文本。 即时通讯使用Aurelia与i18n,一个解决方案将只是有一个方法,返回你想要的。但我想在html中使用它,因为我认为它更清晰,可以根据html代码中的bool来查看该按钮将具有哪些文本。 这是它看起来像现在:根据条件显示HTML按钮上的i18n文本Aurelia
<button>${account.changed ? '_cancel' | t : '_close' | t } </button>
这是我曾尝试:
<button>${account.changed ? ('_cancel' | t) : ('_close' | t) } </button>
<button>${account.changed ? ${'_cancel' | t} : ${'_close' | t} } </button>
我尝试的任何一个崩溃结束:
Error: Parser Error: Conditional expression account.changed ? '_cancel' requires all 3 expressions at column 33 in [account.changed ? '_cancel' | t : '_close' | t ]
我只用i18N喜欢这个到这一点:
<div>${'example | t'}</div>
根据条件之前,不需要更改文本。
要到这里来的人,我解决了这个这样:
innerHTML.bind="!account.changed ? close : cancel"
,并在.js文件
this.close = this.i18n.tr('_close');
this.cancel = this.i18n.tr('_cancel');
我认为它应该以某种方式来实现这一目标是可能的用aurelia直接在HTML中