如何在 Nativescript 中获取 elementById?

How to get elementById in Nativescript?

我将 nativescript 与 vue.js 一起使用,我正在尝试执行类似 DOM 的操作。这是我的模板中的示例代码:

<Label textWrap="true">
    <FormattedString id="formString"
      backgroundColor="yellow"
      effectiveHeight="100"
      effectiveWidth="100%">
      <Span text="This text has a " /> 
    </FormattedString>
 </Label>

我想通过他的id获取标签元素FormattedString - formString 在 javascript 中是这样的:

let fs = doument.getElementById('formString');
我如何在 Nativescript-Vue 中执行此操作? 我知道有库 nativescript-dom,但我不想将整个库用于简单的 getById。

使用Label.getViewById("formString")访问FormattedString的属性。

getViewById 最接近于 javascript getElementById

希望对您有所帮助