0

Nativescript Angular アプリの RadListView Ui リストの itemReorder ブール値を動的に変更しようとしていますが、成功しませんでした。毎回このエラーが発生します: Behavior is not attached to RadListView, use RadListView addbehavior method to attach it.

HTML:

<GridLayout  tkExampleTitle tkToggleNavButton class="proposedLettersRow">
        <RadListView #itemReord [items]="items" selectionBehavior="LongPress" reorderMode = "Drag" [itemReorder]="itemReorder" (itemReordered)="onItemReordered($event)" multipleSelection= "false"
                    >
                <ng-template tkListItemTemplate let-item="item">
                    <GridLayout class="listItemTemplateGrid" >
                        <Label
                            [text]="item"
                            [ngClass]="!isWin ?  'proposed' : 'proposedIsDone'"
                            class="list-group-item ">
                        </Label>
                    </GridLayout>
                </ng-template>

                <ListViewGridLayout tkListViewLayout
                                    scrollDirection="Vertical"
                                    height="150"
                                    ios:itemHeight="150"
                                    spanCount="7"
                                    horizontalAlignment="center">
                </ListViewGridLayout>
        </RadListView>
    </GridLayout>

タイプスクリプト:

最初に this.itemReorder が true に設定されていて、それを false に変更する関数が来て、この関数を実行するとエラーが表示されます。

端末ログ

コード

4

1 に答える 1

0

itemReorder設定がfalse早すぎると思います。イベントtrue中にコンポーネントが必要になる可能性があります。itemReorderedまだオープンソースではないので、これに関する情報はあまりありません。しかし、簡単な回避策は、タイムアウトを追加することです。

public youWin() {
    if (this.newIndex < this.oldIndex) {
        setTimeout(() => {
            this.itemReorder = false;
        }, 100);
    }
}

更新された遊び場

于 2019-01-20T14:03:49.987 に答える