Skip to Content
เมนู
คุณต้องลงทะเบียนเพื่อโต้ตอบกับคอมมูนิตี้
คำถามนี้ถูกตั้งค่าสถานะ
1 ตอบกลับ
1944 มุมมอง

there is a t-ref="xyz" declared and in JS I reference it using this.rootRef=useRef("xyz")

Now how do I change the styles and attributes of this reference div from js.

 to change the value , I did 

this.rootRef.el.value="custom_value";

but this does not work for styling , I tried

this.rootRef.el.style.display="block";


อวตาร
ละทิ้ง
คำตอบที่ดีที่สุด

Hi,

We cannot style the divs using useREF hooks, if you want to change you can directly use the 

this.$el.find() = class name to apply the styles.
For eg: this.$el.find('button.btn:visible')

Hope it helps

อวตาร
ละทิ้ง
ผู้เขียน

i actually did style it using t-ref:

this.rootRef=useRef("xyz");
this.rootRef.el.style['display']="block";

apparently this worked

Related Posts ตอบกลับ มุมมอง กิจกรรม
0
ม.ค. 25
993
0
ก.ย. 23
2932
1
พ.ค. 23
2208
3
ต.ค. 23
5175
3
มิ.ย. 23
4937