0

If in view blade, it's like this :

<ul>
@if ($a)
    @if (!$b)
        <li>
            <p>...</p>
            ...
        </li>
    @endif
@endif
...
</ul>

I want change it to be vue component

I try like this :

<ul>
<li v-if="a" v-if="!b">
    <p>...</p>
    ...
</li>
...
</ul>

Seems it's wrong

How can I do it correctly?

2
  • 1
    Why do you have two v-ifs? v-if="a && !b" should be enough. Commented Apr 13, 2017 at 5:15
  • @Amresh Venugopal, It's Great. Thanks a lot Commented Apr 13, 2017 at 5:18

1 Answer 1

1

You have multiple options either you chain the condition as described by @Amresh Venupogal or you make a nested if just like you did in your bladeview. However it would require you to add an additional html element.

Option A

<ul> 
  <li v-if="a && !b"><p>...</p></li>
</ul>

Option B (obviously worse since you will create empty div's inside your unorderd list)

<ul> 
  <div v-if="a">
     <li v-if="!b"><p>...</p></li>
  </div>
</ul>
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.