Mat*_*ake 4 nativescript angular2-nativescript angular
有没有办法在 Nativescript 中默认“隐藏”元素?
我的组件中有
export class HouseholdContactComponent{
private isLoading = true
}
Run Code Online (Sandbox Code Playgroud)
在我的xml中
<StackLayout [visibility]="isLoading ? 'collapse' : 'visible'">
<Label text="Hi there"></Label>
</StackLayout>
Run Code Online (Sandbox Code Playgroud)
使用此代码,屏幕会闪烁“您好”消息,然后消失。
您应该使用 Angular 指令,而不是使用 [visibility] 属性*ngIf。
<StackLayout *ngIf="!isLoading">
<Label text="Hi there"></Label>
</StackLayout>
Run Code Online (Sandbox Code Playgroud)
附带说明一下,为了绑定到属性 property 并将其绑定到插值 Angular 正在执行的操作,您需要在其前面加上 前缀attr,例如,您需要编写[attr.visibility]而不仅仅是[visibility].
| 归档时间: |
|
| 查看次数: |
1472 次 |
| 最近记录: |