首页 文章

NativeScript选项卡视图属性绑定tabItem错误

提问于
浏览
0

我想用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 directives 默认都包括在内,例如: ButtonTextField 等 . 是 *tabItem 我需要手动导入的特殊指令吗?

顺便说一下,我真正想要做的是在手机底部有一个TabView棒,就像带有几个标签的Dock一样,就像Facebook移动应用程序底座一样 . 有人可以发布代码片段吗?

2 回答

  • 1

    确保在Angular @NgModule 中导入 NativeScriptModule

    import { NativeScriptModule } from 'nativescript-angular/platform';
    ...
    @NgModule({
      imports: [NativeScriptModule, ...]
    })
    

    答案很晚但希望能帮助别人 .

  • 0

    这个问题是在2年前被问到的,但我今天遇到了这个错误,这就是我最终修复它的方法 . 我使用一个结构,其中所有页面都由 PageModule 导入, PageModule 然后由 AppModule 导入 . 手头的问题: PageModule 不知道 NativeScriptModule . 如果将 NativeScriptModule 添加到 PageModule (或其他任何模块)的 import 数组中,则_2483113将解决问题 .

    import { NativeScriptModule } from "nativescript-angular/nativescript.module";
    // Module declaration, not important
    imports = [
        // Other imports
        NativeScriptModule
    ],
    

相关问题