首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >原稿角边抽屉不出现无错误

原稿角边抽屉不出现无错误
EN

Stack Overflow用户
提问于 2017-08-17 14:49:33
回答 2查看 457关注 0票数 1

我正试图开发一个应用程序的本土化成绩单。

我想使用telerik中的侧抽屉,就像过滤面板一样,我将在主内容文本area.The中显示一些数据,问题是我在启动代码时没有错误,只是根本没有sideDrawer。我不知道怎么调试它。

我目前正在尝试为我的应用程序使用这个示例(只有文件的名称):

http://docs.telerik.com/devtools/nativescript-ui/Controls/Angular/SideDrawer/getting-started

filter.component.html:

代码语言:javascript
复制
<RadSideDrawer showOverNavigation="true" tkExampleTitle tkToggleNavButton class="page">
    <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>
        <Label text="Close Drawer" color="lightgray" padding="10" style="horizontal-align: center" (tap)="onCloseDrawerTap()"></Label>
    </StackLayout>
    <StackLayout tkMainContent>
        <Label [text]="mainContentText" textWrap="true" class="drawerContentText"></Label>
        <Button text="OPEN DRAWER" (tap)="openDrawer()" class="drawerContentButton"></Button>
    </StackLayout>
</RadSideDrawer>

filter.component.ts:

代码语言:javascript
复制
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/sidedrawer/angular";
import { RadSideDrawer } from 'nativescript-telerik-ui/sidedrawer';

@Component({
    moduleId: module.id,
    selector: "tk-sidedrawer-getting-started",
    templateUrl: 'filter.component.html',
    styleUrls: ['filter.component.css']
})
export class SideDrawerGettingStartedComponent 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();
    }
}  

filter.module.ts:

代码语言:javascript
复制
import { NgModule, NO_ERRORS_SCHEMA } from "@angular/core";
import { NativeScriptModule } from "nativescript-angular/nativescript.module";
import { NativeScriptUISideDrawerModule } from "nativescript-telerik-ui/sidedrawer/angular";


import { FilterRoutingModule } from "./filter.routing";
import { SideDrawerGettingStartedComponent } from "./filter.component";

@NgModule({
    imports: [
        NativeScriptModule,
        FilterRoutingModule,
        NativeScriptUISideDrawerModule
    ],
    declarations: [
        SideDrawerGettingStartedComponent
    ],
    schemas: [
        NO_ERRORS_SCHEMA
    ]
})
export class FilterModule { }  

filter.routing.ts:

代码语言:javascript
复制
    import { NgModule } from "@angular/core";
    import { Routes } from "@angular/router";
    import { NativeScriptRouterModule } from "nativescript-angular/router";

    import { SideDrawerGettingStartedComponent } from "./filter.component";

    const routes: Routes = [
        { path: "filter", component: SideDrawerGettingStartedComponent }
    ];

    @NgModule({
        imports: [NativeScriptRouterModule.forChild(routes)],
        exports: [NativeScriptRouterModule]
    })
    export class FilterRoutingModule { }  

filter.component.css:

代码语言:javascript
复制
 button {
    font-size: 15;
    horizontal-align: center;
}

.mainContentText {
    font-size: 13;
    padding: 10;
}

.mainContentButton {
    margin: 10;
    horizontal-align: left;
}

.drawerContentButton {
    color: yellowgreen;
}

.sideStackLayout {
    background-color: gray;
}

.sideTitleStackLayout {
    height: 56;
    text-align: center;
    vertical-align: center;
}

.sideLabel {
    padding: 10;
}

.sideLightGrayLabel {
    background-color: lightgray;
} 

当我转到这个过滤页面时,侧抽屉根本不出现。我的应用程序的结构类似于这个结构:https://github.com/NativeScript/sample-Groceries

任何帮助都将不胜感激。

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2017-08-21 15:33:57

我通过在package.json文件中添加一些依赖项来解决我的问题。

为此,我创建了一个新的空白生成项目,并安装了RadSideDrawer,并比较了我所拥有和升级的依赖项,并添加了其中一些依赖项(例如,我的依赖项列表中没有@角/动画)

票数 0
EN

Stack Overflow用户

发布于 2017-08-19 21:58:01

你得到什么信号了吗?你确定你的按钮标签有效吗?否则,我就把它用于我的项目:我给了RadSideDrawer一个ID

代码语言:javascript
复制
<RadSideDrawer #drawer showOverNavigation="true" tkExampleTitle tkToggleNavButton class="page">

并像这样使用@ViewChild:

代码语言:javascript
复制
@ViewChild('drawer') public drawerComponent: RadSideDrawerComponent;

如果你有解决办法就告诉我。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/45738387

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档