错误 NativeScript - 显示空应用程序而不是内容

Error NativeScript- empty app is shown instead of content

我使用 Angular v7 创建了一个网络应用程序,现在我想将我的网络应用程序迁移到 NativeScript 移动应用程序。我按照 NativeScript 官方网站上的说明进行操作,一切正常,直到我为移动应用程序调整了我的代码。

当我 运行 现在我的应用程序在我的 Android 移动设备中时,我收到错误消息

View not added to this instance view stacklayout(2), CurrentParent undefned, ExpectedParent: AppHostView(1)

有时我只看到一个空的应用程序。我究竟做错了什么?抱歉,我是迁移和代码共享的新手。

我的app.component.tns.html:

<!-- https://docs.nativescript.org/angular/core-concepts/angular-navigation.html#page-router-outlet -->
<StackLayout class="text-align:center">
    <Label>
      Welcome to {{ title }}!
    </Label>
</StackLayout>
<weather-search></weather-search>
<weather-list></weather-list>
<page-router-outlet></page-router-outlet>

我的天气-list.component.tns.html:

<StackLayout class="weather-list">
  <weather-item *ngFor="let weatherItem of weatherItems" [item]="weatherItem"></weather-item>
</StackLayout>

<!--
Original Web template:

<section class="weather-list">
    <weather-item *ngFor="let weatherItem of weatherItems" [item]="weatherItem"></weather-item>
</section>
-->

我的天气-search.component.tns.html:

<FlexboxLayout class="weather-search">
    <StackLayout class="test_up">
        <Label class="city" text="City"></Label>
        <TextField name="location" id="city" ngModel required></TextField>
    </StackLayout>
    <StackLayout class="test_down">
        <Label class="city" text="Country Code"></Label>
        <TextField name="countryCode" id="code" ngModel required></TextField>
        <Button text="Add City" (tap)="onSubmit(f)"></Button>
    </StackLayout>
</FlexboxLayout>
<Button text="Get geolocation" (tap)="onClickLocationData(f)"></Button>
<Label class="map" *ngIf="latitude!=0" text="{{latitude}}"></Label>
<Label class="map" *ngIf="longitude!=0" text="{{longitude}}"></Label>
<StackLayout id="map" class="mapLocation"></StackLayout>

<!--
Original Web template:

<section class="weather-search">
    <form (ngSubmit)="onSubmit(f)" #f="ngForm">
        <div class="test_up">
            <label for="city" class="city">City</label>
            <input name="location" type="text" id="city" ngModel required>
        </div>
        <div class="test_down">
            <label for="countryCode" class="city">Country Code</label>
            <input name="countryCode" type="text" id="code" ngModel required>
        </div>
        <button type="submit">Add City</button>
    </form>
    <button (click)="onClickLocationData(f)">Get geolocation</button>
    <label for="latitude" class="map" *ngIf="latitude!=0">Latitude: {{latitude}} </label>
    <label for="longitude" class="map" *ngIf="longitude!=0">Longitude: {{longitude}} </label>
    <div id="map" class="mapLocation"></div>
</section>
-->

我的天气-item.component.tns.html:

<StackLayout class="weather-element">
    <StackLayout class="col-1">
        <Label text="{{ weatherItem.cityName }}"></Label>
        <Label class="info" text="{{ weatherItem.description }}"></Label>
    </StackLayout>
    <StackLayout class="col-2">
        <Label class="temperature" text="{{ weatherItem.temperature }}"></Label>
    </StackLayout>
</StackLayout>

<!--
Original Web template:

<article class="weather-element">
    <div class="col-1"> 
        <h3>{{ weatherItem.cityName }}</h3>
        <p class="info">{{ weatherItem.description }}</p>
    </div>
    <div class="col-2"> 
        <span class="temperature">{{ weatherItem.temperature }}°C</span>
    </div>
</article>
-->

我的app-routing.module.tns.ts:

import { NgModule } from '@angular/core';
import { NativeScriptRouterModule } from 'nativescript-angular/router';
import { Routes } from '@angular/router';

const routes: Routes = [];

@NgModule({
  imports: [NativeScriptRouterModule.forRoot(routes)],
  exports: [NativeScriptRouterModule]
})
export class AppRoutingModule { }

您的 app.component.html 元素不能超过一个 UI。您必须用您选择的 UI 布局包装它。