0

Is it possible to use dynamic directives? I want to use v-show or v-if based on props.

E.g. <div :[directiveType]="isActive"></div>

1 Answer 1

3

No, but you can easily use both with common condition. Only tricky part is you want true by default.

<div 
    v-if="isActive || directiveType !== 'if'"
    v-show="isActive || directiveType !== 'show'"
>
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.