2017-08-28 23 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月初開始發佈。 –