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

时间:2016-10-13 05:49:12

标签: nativescript angular2-nativescript

我想用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指令,例如:ButtonTextField等。*tabItem是否需要特殊指令手动导入?

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

3 个答案:

答案 0 :(得分:1)

确保您在Angular responsive: { rules: [{ condition: { maxWidth: 500 }, chartOptions: { legend: { align: 'center', verticalAlign: 'bottom', layout: 'horizontal' }, series: { point: { events: { mouseOver: function () { var chart = this.series.chart; if (!chart.lbl) { chart.lbl = chart.renderer.label('') .add(); } chart.lbl .show() .css({ width: '80' }) .attr({ text: 'this is the text and I have to make it really long so that it goes for multiple lines' }); chart.lbl.align(Highcharts.extend(chart.lbl.getBBox(), { align: 'right', x: 0, // offset verticalAlign: 'top', y: 50 // offset }), null, 'spacingBox'); } } } }, 中导入NativeScriptModule

@NgModule

答案很晚,但希望能有所帮助。

答案 1 :(得分:0)

这个问题是2年前提出的,但是今天我遇到了这个错误,这就是我最终解决它的方法。我使用一种结构,其中所有页面均由PageModule导入,然后PageModuleAppModule导入。当前的问题:PageModule不了解NativeScriptModule。如果将NativeScriptModule添加到import的{​​{1}}数组中(或正在使用的任何其他模块,可能用于导入Components或其他任何东西),它将解决此问题。

PageModule

答案 2 :(得分:0)

公共模块是您需要导入的所有模块,它负责tabViews及其所有子属性和元素。

import { NativeScriptCommonModule } from 'nativescript-angular/common';

别忘了安装在您的导入文件中。

@NgModule({
  imports: [NativeScriptCommonModule, ...]
})