A
A
artloveyou2021-11-03 17:30:22
Vue.js
artloveyou, 2021-11-03 17:30:22

How to pass a prop depending on a condition?

There is a component <component></component>

Depending on the condition, I need to have two
<component left></component>
<component right></component>

options <component :dir="getDir()"></component>: it is necessary that the name of the props change
And it does not suit me

<component v-if="left" left></component>
<component v-else right></component>
because there is a lot of code inside the component plus recursive code, and then it will have to be taken out additionally. Question: is there such a possibility?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dmitry Gololobov, 2021-11-03
@artloveyou

<component>
     :left="true"
     :right="false"
</component>

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question