Solutons Lounge

How to set html attributes dynamically? – How do I?


What is the correct format to set the HTML attributes of an element dynamically, for example I want to set several attributes dynamically.

Captura de Tela 2024-07-21 às 18.06.40

I tried to map an object but it didn’t work. I can only do so if the attribute and value are individual. However, in a component I will need to define it dynamically depending on the properties selected in the component.

I think it could be something like:
[{key: "data-attribute", value:"first-value"}, ..] this was the structure that WeWeb used fro Supabase metadata as well, so I think this might be the convention across the app.



Source link

Exit mobile version