How to get elementById in Nativescript?

£可爱£侵袭症+ 提交于 2021-02-04 18:56:11

问题


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.


回答1:


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

getViewById is the nearest equivalent to the javascript getElementById

Hope this helps



来源:https://stackoverflow.com/questions/56316914/how-to-get-elementbyid-in-nativescript

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!