gpt4 book ai didi

angular - 如何在 nativescript 中更改侧抽屉的位置/位置

转载 作者:搜寻专家 更新时间:2023-10-30 21:39:50 24 4
gpt4 key购买 nike

我正在学习 nativescript。我想更改从右侧打开的应用程序中侧边栏的方向(现在它是从左侧打开的)。我该怎么做?

这是我的代码:

应用程序组件.html:

<RadSideDrawer tkExampleTitle tkToggleNavButton>
<StackLayout tkDrawerContent class="sideStackLayout">
<StackLayout class="sideTitleStackLayout">
<Label text="Navigation Menu"></Label>
</StackLayout>
<StackLayout class="sideStackLayout">
<Label text="Primary" class="sideLabel sideLightGrayLabel"></Label>
<Label text="Social" class="sideLabel"></Label>
<Label text="Promotions" class="sideLabel"></Label>
<Label text="Labels" class="sideLabel sideLightGrayLabel"></Label>
<Label text="Important" class="sideLabel"></Label>
<Label text="Starred" class="sideLabel"></Label>
<Label text="Sent Mail" class="sideLabel"></Label>
<Label text="Drafts" class="sideLabel"></Label>
</StackLayout>
<Button text="Close Drawer" (tap)="onCloseDrawerTap()"></Button>
</StackLayout>
<StackLayout tkMainContent>
<Label [text]="mainContentText" textWrap="true" class="drawerContentText"></Label>
<Button text="OPEN DRAWER" (tap)="openDrawer()" class="drawerContentButton"></Button>
</StackLayout>
</RadSideDrawer>

应用程序组件.ts:

import { Component, ViewChild, OnInit, AfterViewInit, ChangeDetectorRef } from "@angular/core";
import { Page } from "ui/page";
import { ActionItem } from "ui/action-bar";
import { Observable } from "data/observable";
import { RadSideDrawerComponent, SideDrawerType } from "nativescript-telerik-ui-pro/sidedrawer/angular";
import { RadSideDrawer } from 'nativescript-telerik-ui-pro/sidedrawer';


@Component({
moduleId: module.id,
selector: "tk-sidedrawer-getting-started",
templateUrl: 'app.component.html',
styleUrls: ['app.component.css']
})
export class AppComponent implements AfterViewInit, OnInit {
private _mainContentText: string;

constructor(private _changeDetectionRef: ChangeDetectorRef) {
}

@ViewChild(RadSideDrawerComponent) public drawerComponent: RadSideDrawerComponent;
private drawer: RadSideDrawer;

ngAfterViewInit() {
this.drawer = this.drawerComponent.sideDrawer;
this._changeDetectionRef.detectChanges();
}

ngOnInit() {
this.mainContentText = "SideDrawer for NativeScript can be easily setup in the HTML definition of your page by defining tkDrawerContent and tkMainContent. The component has a default transition and position and also exposes notifications related to changes in its state. Swipe from left to open side drawer.";
}

get mainContentText() {
return this._mainContentText;
}

set mainContentText(value: string) {
this._mainContentText = value;
}

public openDrawer() {
this.drawer.showDrawer();
}

public onCloseDrawerTap() {
this.drawer.closeDrawer();
}

}

应用程序模块.ts:

 import { NgModule, NO_ERRORS_SCHEMA } from "@angular/core";
import { NativeScriptModule } from "nativescript-angular/nativescript.module";
import { NativeScriptUISideDrawerModule } from 'nativescript-telerik-ui-pro/sidedrawer/angular'

import { AppComponent } from "./app.component";

@NgModule({
declarations: [AppComponent],
bootstrap: [AppComponent],
imports: [NativeScriptModule, NativeScriptUISideDrawerModule ],
schemas: [NO_ERRORS_SCHEMA],
})
export class AppModule {}

最佳答案

nativescript-telerik0ui 插件中的 RadSideDrawer 支持通过其 drawerLocation 属性更改其位置。该属性可以设置为:

  • 置顶
  • 底部

您可以引用文档中的更多信息 here或 sdk Angular 示例 here .

关于angular - 如何在 nativescript 中更改侧抽屉的位置/位置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44081492/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com