2016-08-24 125 views
0

我想在DOM中添加新消息時播放動畫。在nativescript中使用querySelector;

,但我不知道如何找到我的對象和(this.zone.run)函數的代碼編輯:

addMessage(message: string){ 
    this.messages.unshift(message); 
    // renderer 
    this.zone.run(() => { 

    }); 
} 

這裏的app.component.html

<StackLayout #container> 
    <ScrollView> 
     <WrapLayout #red> 
      <Label class="message" *ngFor="let message of messages" [text]="message"></Label> 
     </WrapLayout> 
    </ScrollView> 
</StackLayout> 

我想編輯WrapLayout元素的第一個子元素

回答

0

沒有NativeScript的DOM。

然而,一個主要的社區貢獻者編寫了一個插件來幫助Web開發人員使用NativeScript將本地開發轉換爲本地開發。這個插件提供了你會發現web和DOM熟悉的幫助器方法。 https://github.com/NathanaelA/nativescript-dom

請記住,這些輔助方法不是NativeScript提供的開箱即用方法。您可以通過NativeScript中的id以幾種方式在不同的事件(頁面/框架和組件級別)中獲取任何視圖。

我記得有一個與NativeScript與角度沒有頁面組件,但我覺得你還是有框架模塊,你可以做類似

frame.topmost().currentPage.getViewById('yourID');

確保您導入(需要)的框架模塊。