2017-08-28 21 views
2

我已经使用RadListView如下,但我已经非常奇怪的错误:NativeScript RadListView rootLocator不是一个函数

 <RadListView [items]="dataItems"> 
      <ng-template tkListItemTemplate let-item="item"> 
       <StackLayout orientation="vertical"> 
        <Label class="nameLabel" [text]="item.title"></Label> 
       </StackLayout> 
      </ng-template> 
     </RadListView> 

就像,因为它是在这里https://github.com/telerik/nativescript-ui-samples-angular/tree/release/sdkAngular/app/listview/getting-started
但问题是,我得到以下异常: enter image description here

回答

2

问题是依赖关系。我根据this文件更新了依赖关系和版本号,如here所述。现在它的工作很好。

2

尝试升级所有的依赖在你package.json文件,同时遵循下面附加的样品,并尝试重新构建应用程序。

{ 
    "description": "NativeScript Application", 
    "license": "SEE LICENSE IN <your-license-filename>", 
    "readme": "NativeScript Application", 
    "repository": "<fill-your-repository-here>", 
    "nativescript": { 
    "id": "org.nativescript.test" 
    }, 
    "dependencies": { 
    "@angular/animations": "~4.2.0", 
    "@angular/common": "~4.2.0", 
    "@angular/compiler": "~4.2.0", 
    "@angular/core": "~4.2.0", 
    "@angular/forms": "~4.2.0", 
    "@angular/http": "~4.2.0", 
    "@angular/platform-browser": "~4.2.0", 
    "@angular/router": "~4.2.0", 
    "nativescript-angular": "~4.2.0", 
    "nativescript-telerik-ui-pro": "^3.0.4", 
    "nativescript-theme-core": "~1.0.2", 
    "reflect-metadata": "~0.1.8", 
    "rxjs": "~5.4.2", 
    "tns-core-modules": "~3.1.0", 
    "zone.js": "~0.8.2" 
    }, 
    "devDependencies": { 
    "nativescript-dev-typescript": "~0.5.0", 
    "typescript": "~2.4.2" 
    } 
} 

请记住在重建之前再次删除node_modules,platforms和hooks文件夹。

+0

我升级了它。问题仍然存在... –

+1

确保在执行tns运行之前删除node_modules和平台文件夹。如果以前的版本是从npm下载的,那么即使更新了package.json,也可能会使用旧版本运行。请注意,当前版本的nativescript-telerik-ui已经为'Angular:〜4.1.0'和'nativescript-angular:3.1.3'开发。支持所有最新依赖项的版本将于9月初开始发布。 –