name: pane.name || index,
bool: pane.closable,
});
if (!pane.name) pane.name = index;
if (index === 0) {
if (!_this.currentValue) {
_this.currentValue = pane.name || index;
}
}
});
this.updateStatus();
},
updateStatus() {
var tabs = this.getTabs();
var _this = this;
tabs.forEach(function (tab) {
return (tab.show = tab.name === _this.currentValue);
});
},
handleChange: function (index) {
var nav = this.navList[index];
var name = nav.name;
this.currentValue = name;
this.$emit('input', name);
// this.$emit('on-click', name);
},
removePane: function () {
var bool = this.navList[1].bool;
console.log(bool);
if (bool) {
this.navList[1].bool = false;
this.currentValue = '0';
}
if (!bool) {
this.navList[1].bool = true;
this.currentValue = '1';
this.$emit('input', '1');
}
},
},
watch: {
value: function (val) {
this.currentValue = val;
},
currentValue: function () {
console.log('demo');
this.updateStatus();
},
},
});
//pane.js
Vue.component('pane', {
name: 'pane',
template: `
<div class="pane" v-if="show">
<slot> </slot>
</div>
`,
props: {
name: {
type: String
},
label: {
type: String,
default: ''
},
closable: {
type: Boolean,
default: true
}
}, data: function () {
return {
show: true
}
},
methods: {
updateNav() {
this.$parent.updateNav();
}
},
watch: {
label() {
this.updateNav();
}
},
mounted() {
this.updateNav();
}
})
//style.css
.tabs {
font-size: 14px;
color: black;
}.tabs-bar:after {
content: '';
display: block;
width: 100%;
height: 1px;
position: relative;
background: rgba(78, 81, 128, 0.5);
}
.tabs-tab {
display: inline-block;
padding: 4px 16px;
margin-right: 6px;
color: rgba(0, 0, 0, 0.6);
background: rgba(134, 134, 131, 0.137);
border: 1px solid rgba(154, 214, 248, 0.856);
cursor: pointer;
position: relative;
}
.tabs-tab-active {
background: rgb(252, 251, 251);
color: rgba(0, 0, 0, 1);
border-top: 1px solid rgba(154, 214, 248, 0.856);
border-bottom: 1px solid white;
}
/* .tabs-tab-active:before {
content: '';
display: block;
height: 5px;
background: grey;
position: absolute;
top: 0;
left: 0;
right: 0;
} */










