我正在尝试在本机脚本中创建示例应用程序。我通过引用http://docs.telerik.com/devtools/nativescript-ui/Controls/Angular/SideDrawer/getting-started以下列方式将 RadSideDrawer 用于 sidemenu :
<RadSideDrawer [transition]="RevealTransition" #drawer>
<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>
</StackLayout>
<StackLayout tkMainContent>
<GridLayout rows="*">
<page-router-outlet ></page-router-outlet>
<ActivityIndicator #activityIndicator horizontalAlignment="center" verticalAlignment="center" width="100" height="100" row="0"></ActivityIndicator>
</GridLayout>
</StackLayout>
</RadSideDrawer>
在我的 app.component.ts 中,我给出了:
import {RadSideDrawer} from "nativescript-telerik-ui/sidedrawer";
@ViewChild("drawer") drawer : ElementRef;
和
public toggleDrawer(){
let drawer = <RadSideDrawer>this.drawer.nativeElement;
drawer.toggleDrawerState();
}
问题是,每当我尝试执行 toggleDrawer() 时,都会出现错误:
drawer.toggleDrawerState not a function.
可能出了什么问题?我将 this.drawer 作为 [object Object] 并将 this.drawer.nativeElement 作为 ProxyViewContainer(5),这意味着它正在识别元素,但不能调用 toggleDrawerState();
现在样式也被扭曲了,它现在在主视图中列出了 tkDrawerContent,我无法看到我在 tkMainContent 中指定的原始页面内容。