【发布时间】:2016-10-13 05:49:12
【问题描述】:
我想用 Angular 2.0.1、NativeScript 2.3.0 实现 TabView。我遵循这个官方指南here,但在下面遇到了一个问题。
<TabView #tabview>
[ERROR ->]<StackLayout *tabItem="{title: 'Profile'}" >
<ListView [items]='items'>
<template let-i"): LoginComponent@17:4
Property binding tabItem not used by any directive on an embedded template. Make sure that the property name is spelled correctly and all directives are listed in the "directives" section. ("
</ListView>
</StackLayout>
[ERROR ->]<StackLayout *tabItem="{title: 'Stats'}">
<Label text="Second tab item"></Label>
</StackLay"): LoginComponent@24:4
Property binding tabItem not used by any directive on an embedded template. Make sure that the property name is spelled correctly and all directives are listed in the "directives" section. ("
<Label text="Second tab item"></Label>
</StackLayout>
[ERROR ->]<StackLayout *tabItem="{title: 'Settings'}">
<Label text="Third tab item"></Label>
我从编译器得到的错误是
Property binding tabItem not used by any directive on an embedded template. Make sure that the property name is spelled correctly and all directives are listed in the "directives" section.
我以为所有的 nativescript 指令 都已默认包含,例如:Button、TextField 等。*tabItem 是我需要手动导入的特殊指令吗?
顺便说一句,我真正想做的是在手机底部有一个 TabView 棒,就像带有几个标签的 Dock,就像 Facebook 移动应用程序坞一样。谁能发个代码sn-p?
【问题讨论】:
-
在 Android 和 iOS 上测试文章中的示例时,我无法重现问题。关于这一点,如果您可以在使用 TabView 组件的地方共享代码,这将有所帮助。此时,对于 Android,TabView 的选项卡将始终位于顶部,并且它们的位置无法更改。为了您的目的,您可以使用 SegmentedBar 并手动控制布局的可见性 - github.com/NativeScript/nativescript-sdk-examples-ng/tree/…。
标签: nativescript angular2-nativescript