stanimirsp
stanimirsp

Reputation: 3086

How to get elementById in Nativescript?

I'm using nativescript with vue.js and I'm trying to do something like DOM operation. This is sample code from my template:

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

I want to get tag element FormattedString by his id - formString In javascript is like this:

let fs = doument.getElementById('formString');
How can I do this in Nativescript-Vue? I know that there is library nativescript-dom, but I don't want to use whole library for simple getById.

Upvotes: 4

Views: 4544

Answers (1)

Rachel Gallen
Rachel Gallen

Reputation: 28573

Use Label.getViewById("formString") to access the attributes of FormattedString.

getViewById is the nearest equivalent to the javascript getElementById

Hope this helps

Upvotes: 5

Related Questions