2016-08-24 82 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');

确保您导入(需要)的框架模块。