Jon Sud
Jon Sud

Reputation: 11661

How to render attribute-property by condition in Vue?

In Vue, how to render to property by condition?

for example I have this markup and by set clickable=true then this div will have :to property if not, will have regular div (no :to).

<div :to="path">
  <img src="..." />
</div>

Upvotes: 0

Views: 51

Answers (2)

Shlomi Levi
Shlomi Levi

Reputation: 3315

Try this:

<div :to="false && path">
  <img src="..." />
</div>

Upvotes: 1

RAJEESH PM
RAJEESH PM

Reputation: 83

I think you can use something like this:

   <div v-if="clickable" :to="path">
      <img src="..." />
   </div>
   <div v-else>
      <img src="..." />
   </div>

Upvotes: 0

Related Questions