Android 如何添加侧抽屉?[Nativescript+;Angular]
在主模块中,我添加了以下内容:Android 如何添加侧抽屉?[Nativescript+;Angular],android,angularjs,nativescript,angular2-nativescript,Android,Angularjs,Nativescript,Angular2 Nativescript,在主模块中,我添加了以下内容: import {SIDEDRAWER_DIRECTIVES} from "nativescript-telerik-ui/sidedrawer/angular"; ... declarations: [ SIDEDRAWER_DIRECTIVES, AppComponent, ...AppComponents ] app.component.html的xml部分: <RadSideDrawer [drawer
import {SIDEDRAWER_DIRECTIVES} from "nativescript-telerik-ui/sidedrawer/angular";
...
declarations: [
SIDEDRAWER_DIRECTIVES,
AppComponent,
...AppComponents
]
app.component.html的xml部分:
<RadSideDrawer [drawerLocation]="currentLocation" 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>
</StackLayout>
<StackLayout tkMainContent>
<Label [text]="mainContentText" textWrap="true" class="drawerContentText"></Label>
<Button text="OPEN DRAWER" (tap)=openDrawer()></Button>
</StackLayout>
</RadSideDrawer>
当我尝试运行它时,我得到一个错误:
“主”线程上发生未捕获的异常。
com.tns.NativeScriptException:在CreateView上调用js方法失败
TypeError:无法读取未定义文件的属性“android”:
"file:///data/data/org.nativescript.nativescript/files/app/tns_modules/nativescript-telerik-ui/sidedrawer/sidedrawer.js,
行:91,列:39
StackTrace:Frame:function:'RadSideDrawer.initOldDrawer',
档案:'file:///data/data/org.nativescript.nativescript/files/app/tns_modules/nativescript-telerik-ui/sidedrawer/sidedrawer.js',
行:91,列:40帧:函数:'RadSideDrawer.\u createUI',
档案:'file:///data/data/org.nativescript.nativescript/files/app/tns_modules/nativescript-telerik-ui/sidedrawer/sidedrawer.js',
行:147,列:18帧:函数:'View.\u onContextChanged',
档案:'file:///data/data/org.nativescript.nativescript/files/app/tns_modules/ui/core/view.js',
行:202,列:14帧:函数:'View.\u onAttached',
档案:'file:///data/data/org.nativescript.nativescript/files/app/tns_modules/ui/core/view.js',
行:1
有人知道什么是问题吗?- 进行此导入:
从“nativescript telerik ui/sidedrawer/angular”导入{NativeScriptUISideDrawerModule};
- 将其添加到导入中:
导入:[
NativeScript UISideDrawerModule,
...
]
现在,您的侧抽屉应该可以正常工作。解决此类问题的更快方法是使用NativeScript Sidekick。选择创建一个新项目。其中一个模板具有侧抽屉功能。我尝试了很多方法使其正常工作,但这是唯一的方法。官方文档不好且没有组织。