Angular2/Nativescript:Strange“;“意外标记”;嵌套堆栈布局时出错

Angular2/Nativescript:Strange“;“意外标记”;嵌套堆栈布局时出错,nativescript,angular2-nativescript,Nativescript,Angular2 Nativescript,我正忙于Angular2 Nativescript应用程序,该应用程序在将输入字段移动到视图的另一部分之前工作得非常好,但在将输入字段移动到视图的另一部分之后,我发现以下错误,称为意外结束标记“StackLayout”。。。你知道这是什么原因吗?可以嵌套在彼此内部的堆栈布局的数量是否有限制?我移动到视图不同部分的输入字段是数量输入字段 我得到的错误是: JS: ns-renderer: ERROR BOOTSTRAPPING ANGULAR JS: ns-renderer: Template p

我正忙于Angular2 Nativescript应用程序,该应用程序在将输入字段移动到视图的另一部分之前工作得非常好,但在将输入字段移动到视图的另一部分之后,我发现以下错误,称为意外结束标记“StackLayout”。。。你知道这是什么原因吗?可以嵌套在彼此内部的堆栈布局的数量是否有限制?我移动到视图不同部分的输入字段是数量输入字段

我得到的错误是:

JS: ns-renderer: ERROR BOOTSTRAPPING ANGULAR
JS: ns-renderer: Template parse errors:
JS: Unexpected closing tag "StackLayout" ("Field class="input input-border" hint="Enter Quantity" keyboardType="number" [(ngModel)]="qty">
JS:                             [ERROR ->]</StackLayout>
JS:                             <Button class="btn btn-primary pull-right font-awesome" text="&#xf058;  Capture" ("): StockTakeComponent@37:4
JS: Unexpected closing tag "StackLayout" ("me" text="&#xf058;  Capture" (tap)="capture()" [isEnabled]="qty !== '' && qty != null"></Button>
JS:                     [ERROR ->]</StackLayout>
JS:             </StackLayout>
JS:
JS: "): StockTakeComponent@39:3
JS: Unexpected closing tag "StackLayout" (";  Capture" (tap)="capture()" [isEnabled]="qty !== '' && qty != null"></Button>
JS:                     </StackLayout>
JS:             [ERROR ->]</StackLayout>
JS:
JS:             <StackLayout *ngFor="let item of stockTakeDetailList" *ngIf="stockTakeDetailList.l"): StockTakeComponent@40:2
JS: Unexpected closing tag "StackLayout" ("nt-awesome" text="&#xf1f8; remove" (tap)="removeCaptureItem(item.IDKey)"></Button>
JS:     </StackLayout>
JS:     [ERROR ->]</StackLayout>
JS: </StackLayout>"): StockTakeComponent@47:1
JS: Unexpected closing tag "StackLayout" ("
JS:     </StackLayout>
JS:     </StackLayout>
JS: [ERROR ->]</StackLayout>"): StockTakeComponent@48:0
JS:
JS: Error: Template parse errors:
JS: Unexpected closing tag "StackLayout" ("Field class="input input-border" hint="Enter Quantity" keyboardType="number" [(ngModel)]="qty">
JS:                             [ERROR ->]</StackLayout>
JS:                             <Button class="btn btn-primary pull-right font-awesome" text="&#xf058;  Capture" ("): StockTakeComponent@37:4
JS: Unexpected closing tag "StackLayout" ("me" text="&#xf058;  Capture" (tap)="capture()" [isEnabled]="qty !== '' && qty != null"></Button>
JS:                     [ERROR ->]</StackLayout>
JS:             </StackLayout>
JS:
JS: "): StockTakeComponent@39:3
JS: Unexpected closing tag "StackLayout" (";  Capture" (tap)="capture()" [isEnabled]="qty !== '' && qty != null"></Button>
JS:                     </StackLayout>
JS:             [ERROR ->]</StackLayout>
JS:
JS:             <StackLayout *ngFor="let item of stockTakeDetailList" *ngIf="stockTakeDetailList.l"): StockTakeComponent@40:2
JS: Unexpected closing tag "StackLayout" ("nt-awesome" text="&#xf1f8; remove" (tap)="removeCaptureItem(item.IDKey)"></Button>
JS:     </StackLayout>
JS:     [ERROR ->]</StackLayout>
JS: </StackLayout>"): StockTakeComponent@47:1
JS: Unexpected closing tag "StackLayout" ("
JS:     </StackLayout>
JS:     </StackLayout>
JS: [ERROR ->]</StackLayout>"): StockTakeComponent@48:0
JS:     at DirectiveNormalizer.normalizeLoadedTemplate (/data/data/org.nativescript.barcodescanner/files/app/tns_modules/@angular/compiler/bundles/compiler.umd.js:13337:21)
JS:     at /data/data/org.nativescript.barcodescanner/files/app/tns_modules/@angular/compiler/bundles/compiler.umd.js:13324:53
JS:     at ZoneDelegate.invoke (/data/data/org.nativescript.barcodescanner/files/app/tns_modules/nativescript-angular/zone-js/dist/zone-nativescript.js:190:28)
JS:     at Zone.run (/data/data/org.nativescript.barcodescanner/files/app/tns_modules/nativescript-angular/zone-js/dist/zone-nativescript.js:83:43)
JS:     at /data/data/org.nativescript.barcodescanner/files/app/tns_modules/nativescript-angular/zone-js/dist/zone-nativescript.js:449:57
JS:     at ZoneDelegate.invokeTask (/data/data/org.nativescript.barcodescanner/files/app/tns_modules/nativescript-angular/zone-js/dist/zone-nativescript.js:223:37)
JS:     at Zone.runTask (/data/data/org.nativescript.barcodescanner/files/app/tns_modules/nativescript-angular/zone-js/dist/zone-nativescript.js:123:47)
JS:     at drainMicroTaskQueue (/data/data/org.nativescript.barcodescanner/files/app/tns_modules/nativescript-angular/zone-js/dist/zone-nativescript.js:355:35)
1:54:21 PM - Compilation complete. Watching for file changes.
JS:ns渲染器:启动时出错
JS:ns呈现程序:模板分析错误:
JS:意外的结束标记“StackLayout”(“Field class=“input border”hint=“Enter Quantity”keyboardType=“number”[(ngModel)]=“qty”>
JS:[错误->]
JS:
JS:
JS:[错误->]
JS:
JS:
JS:
JS:[错误->]
JS:):StockTakeComponent@47:1
JS:意外的结束标记“StackLayout”(“
JS:
JS:
JS:[错误->]”:StockTakeComponent@48:0
JS:
JS:Error:Template解析错误:
JS:意外的结束标记“StackLayout”(“Field class=“input border”hint=“Enter Quantity”keyboardType=“number”[(ngModel)]=“qty”>
JS:[错误->]
JS:
JS:
JS:[错误->]
JS:
JS:
JS:
JS:[错误->]
JS:):StockTakeComponent@47:1
JS:意外的结束标记“StackLayout”(“
JS:
JS:
JS:[错误->]”:StockTakeComponent@48:0
JS:DirectiveNormalizer.normalizeLoadedTemplate(/data/data/org.nativescript.barcodescanner/files/app/tns_modules/@angular/compiler/bundles/compiler.umd.JS:13337:21)
JS:at/data/data/org.nativescript.barcodescanner/files/app/tns_modules/@angular/compiler/bundles/compiler.umd.JS:13324:53
JS:ZoneDelegate.invoke(/data/data/org.nativescript.barcodescanner/files/app/tns_modules/nativescript angular/zone JS/dist/zone nativescript.JS:190:28)
JS:at Zone.run(/data/data/org.nativescript.barcodescanner/files/app/tns_modules/nativescript angular/Zone JS/dist/Zone nativescript.JS:83:43)
JS:at/data/data/org.nativescript.barcodescanner/files/app/tns_modules/nativescript angular/zone JS/dist/zone nativescript.JS:449:57
JS:ZoneDelegate.invokeTask(/data/data/org.nativescript.barcodescanner/files/app/tns_modules/nativescript angular/zone JS/dist/zone nativescript.JS:223:37)
JS:at Zone.runTask(/data/data/org.nativescript.barcodescanner/files/app/tns_modules/nativescript angular/Zone JS/dist/Zone nativescript.JS:123:47)
JS:at drainMicroTaskQueue(/data/data/org.nativescript.barcodescanner/files/app/tns_modules/nativescript angular/zone JS/dist/zone nativescript.JS:355:35)
下午1:54:21-编译完成。监视文件更改。
下面是我的组件HTML代码:

<StackLayout class="page">
    <ActionBar title="Stock Take" android.icon="res://icon" android.iconVisibility="always"></ActionBar>
    <StackLayout *ngIf="!stockTaking">
        <Label class="h1 title m-x-auto" text="Begin Stock Take?"></Label>
        <StackLayout class="form">  
            <StackLayout class="input-field">               
                <ListView [items]="activeStockTakes" class="list-group" (itemTap)="selectActiveStockTake($event.target.value)">
                <template let-activeStockTake="item">
                <StackLayout>
                    <Label class="list-group-item" [text]="activeStockTake.UserCode + ' - ' + activeStockTake.Comment"></Label>
                </StackLayout>
                </template>
                </ListView>
                <TextField class="input input-border tf" hint="Enter Sheet Number" placeholderColor="white" [(ngModel)]="sheetNo"></TextField>
                <TextField class="input input-border" hint="Enter Bin Number" [(ngModel)]="binNo"></TextField>          
            </StackLayout>
            <Button class="btn btn-primary font-awesome" text="&#xf04b; Start Stock Take" (tap)="startStockTake()" [isEnabled]="sheetNo !== '' && sheetNo != null && binNo !== '' && binNo != null"></Button>
        </StackLayout>
    </StackLayout>
    <StackLayout *ngIf="stockTaking">
        <StackLayout class="form">
            <Button id="endStockTakeBtn" class="btn pull-right font-awesome" text="&#xf00d; End Stock Take" (tap)="endStockTake()"></Button>
            <StackLayout class="input-field">       
                <TextField class="input input-border" hint="Enter Barcode" keyboardType="number" [(ngModel)]="barcode"></TextField>     
            </StackLayout>

            <Button class="btn btn-primary pull-right" text="Scan" (tap)="scan()" [isEnabled]="barcode !== '' && barcode != null"></Button>

        </StackLayout>
        <StackLayout *ngIf="product" class="m-x-auto">
            <Label class="label text-primary" [text]="'Description:  ' + product.Description"></Label>
            <Label class="label text-primary" [text]="'POS Description: ' + product.POSDescription"></Label>
            <Label class="label text-primary" [text]="'POS price:  R' + product.POSPrice"></Label>
            <Label class="label text-primary" [text]="'Stock On Hand:  ' + product.StockOnHand"></Label>
            <StackLayout class="form">
                <StackLayout class="input-field">
                    <TextField class="input input-border" hint="Enter Quantity" keyboardType="number" [(ngModel)]="qty">
                </StackLayout>              
                <Button class="btn btn-primary pull-right font-awesome" text="&#xf058;  Capture" (tap)="capture()" [isEnabled]="qty !== '' && qty != null"></Button>
            </StackLayout>
        </StackLayout>

        <StackLayout *ngFor="let item of stockTakeDetailList" *ngIf="stockTakeDetailList.length > 0">
            <Label [text]="'Name: ' + item.ProductDetail_Name" class="text-primary"></Label>            
            <Label text="'Qty: ' + item.Qty" class="text-primary"></Label>          
            <Button class="btn btn-primary pull-left font-awesome" text="&#xf1f8; remove" (tap)="removeCaptureItem(item.IDKey)"></Button>
    </StackLayout>
    </StackLayout>
</StackLayout>

我在下面这行中遇到了相同的错误,这是使用字体时出错的原因

nt-awesome" text="&#xf1f8;
并尝试使用以下方法解决此问题:

这是您的问题:

 <StackLayout class="input-field">
       <TextField class="input input-border" hint="Enter Quantity" keyboardType="number" [(ngModel)]="qty">
 </StackLayout>  


您忘记了结束标记
下一个结束标记是它抛出错误的
/StackLayout
,因为它与前面的
文本字段不匹配。

看起来您有一个或两个额外的`tags@mast3rd3mon您在哪里看到这些额外的stackLayout标记?每次它都显示
[错误->]
。要么是这样,要么就是你错过了其他东西的一个接近标签。你需要在这里包括屏幕,以便我们能够了解原因。根据错误mast3rd3mon可能是正确的,您可能在新的StackLayout标记中缺少一个结束标记,或者您有一个额外的结束StackLayout。您可以共享该组件的html吗?谢谢@Nathanel