3

My vue component is like this :

<template>
    <div>
        <div v-if="!list">No results.</div>
        <div v-else class="panel-group" v-for="item in list">
            ...
        </div>
    </div>
</template>
<script>
    export default {
        ...
        computed: {
            list: function() {
                return this.$store.state.order.list
            }
        }
    }
</script>

The result of console.log(this.$store.state.order.list) is like this :

enter image description here

Seems it's a object

I try like that, but when the object empty, it not display <div v-if="!list">No results.</div>

Is there anyone who can help me?

Update :

If no data, the result of console.log(this.$store.state.order.list) is like this :

enter image description here

1 Answer 1

12
<div v-if="Object.keys(list).length === 0">No results.</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.