简体   繁体   English

如何在Vue.js中删除组件及其插槽

[英]How to remove component and its slot in Vue.js

I'm creating component based Tab functionality. 我正在创建基于组件的Tab功能。 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. 我会建议你遵循这个视频laracasts一个更好的代码。

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 检查小提琴

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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