How to add v-if programatically? I'm asking this for automation purposes as there will be hundreds of dynamic variables that may or may not exist. The desired result is We can add custom attributes to elements programmatically using pure JS, like Given the following elements How to add v-if programmatically? I'm asking this for automation purposes as there will be hundreds of dynamic variables that may or may not exist. The expected result is The only step I know of is to useelement.attr('data-attr', someValue)
, but likev-if
What about the Vue directive
ref
to get the element increated()
.
According to the declaration -There will be hundreds of dynamic variables that may or may not exist.But if I see in your comment, you said>No loops. So how do you render dynamic elements?
From my understanding, you want to dynamically bind the data attributes into the HTML template. You can give this solution a try and see if it meets your requirements.
The code snippet above always works with existing dynamic properties.