【问题标题】:Use querySelector in nativescript;在 nativescript 中使用 querySelector;
【发布时间】:2016-08-24 13:24:44
【问题描述】:

我想在 DOM 中添加新消息时播放动画。

但我不知道如何找到我的对象并使用 (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 元素的第一个子元素

【问题讨论】:

    标签: nativescript angular2-nativescript


    【解决方案1】:

    没有带有 NativeScript 的 DOM。

    然而,一位主要的社区贡献者编写了一个插件来帮助 Web 开发人员使用 NativeScript 进行原生开发。这个插件提供了你会发现对 web 和 DOM 很熟悉的辅助方法。 https://github.com/NathanaelA/nativescript-dom

    请记住,这些是辅助方法,并不是 NativeScript 开箱即用的。您可以在 NativeScript 中通过多种方式和在不同事件(页面/框架和组件级别)期间通过其 id 获取任何视图。

    我记得没有带有带有角度的 NativeScript 的页面组件,但我认为您仍然拥有框架模块,您可以执行类似的操作

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

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2023-02-17
      • 2017-02-22
      • 1970-01-01
      • 2020-11-29
      • 2020-05-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多