【发布时间】:2019-01-27 16:37:40
【问题描述】:
我正在尝试使用nativescript-bottom-navigation plugin 在我的应用程序中创建一个简单的固定底部导航栏 - 并且不断出现错误。它不会构建,并且在那个可怕的异常黑屏中显示的许多错误中,是“AHBottomNavigation 不是构造函数”。
我只想要固定导航中的 3 个图标:主页、帐户、程序
我使用的是纯 Javascript,演示教程使用 TypeScript。这可能是问题所在。
我遵循的步骤
- 我使用命令行安装了插件。
- 我将我的图标手动添加到资源文件夹中
我的搜索页面 [导航所在的位置]
<Page
navigatingTo="onNavigatingTo"
xmlns="http://schemas.nativescript.org/tns.xsd"
xmlns:bottomNav="nativescript-bottom-navigation"
class="page">
<ActionBar class="action-bar">
<!--
Use the NavigationButton as a side-drawer button in Android
because ActionItems are shown on the right side of the ActionBar
-->
<NavigationButton ios:visibility="collapsed" icon="res://menu" tap="onDrawerButtonTap"></NavigationButton>
<!--
Use the ActionItem for IOS with position set to left. Using the
NavigationButton as a side-drawer button in iOS is not possible,
because its function is to always navigate back in the application.
-->
<ActionItem icon="res://navigation/menu"
android:visibility="collapsed"
tap="onDrawerButtonTap"
ios.position="left">
</ActionItem>
<Label class="action-bar-title" text="Search"></Label>
</ActionBar>
<GridLayout columns="*"
rows="*, auto">
<StackLayout row="0">
<Label text="content"></Label>
</StackLayout>
<bottomNav:BottomNavigation tabs="{{ tabs }}"
activeColor="green"
inactiveColor="red"
backgroundColor="black"
keyLineColor="black"
row="1"></bottomNav:BottomNavigation>
</GridLayout>
</Page>
这里是……
search-view-model.js
const observableModule = require("tns-core-modules/data/observable");
const SelectedPageService = require("../shared/selected-page-service");
const BottomNavigation = require("nativescript-bottom-navigation").BottomNavigation;
const BottomNavigationTab = require("nativescript-bottom-navigation").BottomNavigationTab;
const OnTabSelectedEventData = require("nativescript-bottom-navigation").OnTabSelectedEventData;
function SearchViewModel() {
SelectedPageService.getInstance().updateSelectedPage("Search");
const viewModel = observableModule.fromObject({
/* Add your view model properties here */
tabs: [
new BottomNavigationTab('First', 'ic_home'),
new BottomNavigationTab('Second', 'ic_view_list'),
new BottomNavigationTab('Third', 'ic_menu')
]
});
return viewModel;
}
module.exports = SearchViewModel;
我无法理解设备上显示的错误屏幕(我正在 Android 设备上进行测试)。
有人知道我哪里出错了吗?任何指针将不胜感激。
谢谢。
【问题讨论】:
-
好像没有安装支持库。您是否尝试过干净的构建?删除
platforms文件夹并再次尝试运行该项目。
标签: nativescript