简体   繁体   中英

How to remove component and its slot in Vue.js

I'm creating component based Tab functionality. Please find the code here

deleteTab: function(selectedTab){
        this.tabs = this.tabs.filter(function(tab){
        return tab._uid != selectedTab._uid
      });
    }

In there I've added remove button, which needs to remove the tab and tab details block. Anyone know how to remove the tab details?

I will suggest you to follow this video laracasts for a better code.

To delete your tab and content, you will need to do:

 deleteTab: function(tab){
  tab.isActive=false;
  index = this.tabs.indexOf(tab);
  if (index > -1) {
            this.tabs.splice(index, 1);
  }
    console.log(tab)
}

check fiddle

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM