我有一个问题,我想显示某些信息,具体取决于信息是否为空。
infowindow.setContent(`<b show.bind="${info != null}> Info : ${info}</b>`);
我似乎无法让它发挥作用。这有可能吗?
答案 0 :(得分:0)
我们假设info
是您班级的属性:
import { observable } from 'aurelia-framework';
export class MyClass {
// if the property is not bindable you should use @observable, otherwise you just keep @bindable
@observable()
private info: string;
private infoChanged() {
const content = info ? `<b> Info : ${info}</b>` : '';
infowindow.setContent(content);
}
}
这比增强更容易,并将解决问题。