[Vuejs]-Hide parent component <button> element in Child component

0👍

It will be a good idea to hide the child.

Or if you want in this specific way, I had cracked the situation like that in react.

I will pass a function from parent to child; this function will update data in parent and that determins weather to show the child component.

new VueComponent('parent', {
    template: `
    <div class="...">
        <child-component v-for="obj in object_list" v-if="obj.show" />
    </div

    data: {
       object_list: [
           {show:true, id:1, ...},
           {show:true, id:2, ...},
           {show:false, id:3, ...}
       ]
    },
    methods: {
        toggle_show: function(item_id){
              let item = this.object_list.filter(_item => {_item.id === item_id})
              item.show = !item.show;
        }
    }
})

Leave a comment