Skip to content

v-if with array #677

@flo-sch

Description

@flo-sch

Could v-if exclude empty arrays ?
Or is there another way to do it ?

For instance, imagine the given Vue :

<section id='container'>
    <div id='list-wrapper' v-if='list << I would here mean : "if list is not empty" >>'>
        <h5>List of things</h5>
        <ul>
            <li v-repeat='item: list'>{{ item }}</li>
        </ul>
    </div>
</section>

new Vue({
    el: '#container',
    data: function () {
        return {
            list: []
        }
    },
    events: {
        'list:add': function (item) {
            this.list.push(item);
        }
    }
});

When list is an empty array, I would prefer the content of <div id='list-wrapper'></div> not to be included in the DOM.
I would prefer it to be included only when I push some items in my listarray.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions