0

How do I validate inside of a loop with v-show empty items with vuejs2. I was trying the following but without any results

<div v-for="user in $store.state.users.data">
   <ul>
       <li v-show="user.mobil !== null ||  user.mobil !== ''" >
              <a v-bind:href="'tel://' + user.mobil"> <i class="fa fa-mobile-phone"></i> <span>{{ user.mobil }} </span></a>
       </li>
   </ul>
</div>

enter image description here

3
  • How does your $store.state.users.data look like? Commented Jun 6, 2018 at 11:52
  • $store.state.users.data is an array of objects fetched from server Commented Jun 6, 2018 at 11:54
  • Can you make an example array with 2,3 of those objects with same structure? Commented Jun 6, 2018 at 11:56

1 Answer 1

1

Compare like v-show="user.mobil":

new Vue({
  el: '#app',
  data: {
    users: [{
        mobil: '123',
        name: 'Foo'
      },
      {
        mobil: '',
        name: 'Bar'
      },
      {
        mobil: null,
        name: 'Baz'
      },
    ]
  }
})
<script src="https://unpkg.com/vue"></script>

<div id="app">
  <div v-for="user in users">
    <ul>
      <li v-show="user.mobil">
        {{user.name}}
      </li>
    </ul>
  </div>
</div>

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.