2016-07-27 06:15:02 +00:00
|
|
|
<script>
|
|
|
|
module.exports = {
|
|
|
|
name: 'el-tab-pane',
|
|
|
|
|
|
|
|
props: {
|
2016-11-18 07:41:08 +00:00
|
|
|
label: String,
|
|
|
|
labelContent: Function,
|
2016-11-23 02:47:12 +00:00
|
|
|
name: String,
|
2016-12-08 02:47:16 +00:00
|
|
|
closable: Boolean,
|
|
|
|
disabled: Boolean
|
2016-07-27 06:15:02 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
counter: 0,
|
|
|
|
transition: '',
|
|
|
|
paneStyle: {
|
|
|
|
position: 'relative'
|
2016-08-12 08:18:36 +00:00
|
|
|
},
|
2016-11-23 02:47:12 +00:00
|
|
|
isClosable: null,
|
2016-11-04 03:28:23 +00:00
|
|
|
index: ''
|
2016-07-27 06:15:02 +00:00
|
|
|
};
|
|
|
|
},
|
|
|
|
|
|
|
|
created() {
|
2016-11-23 02:47:12 +00:00
|
|
|
const propsData = this.$options.propsData;
|
|
|
|
if (propsData && typeof propsData.closable !== 'undefined') {
|
|
|
|
this.isClosable = propsData.closable === '' || propsData.closable;
|
|
|
|
} else {
|
|
|
|
this.isClosable = this.$parent.closable;
|
|
|
|
}
|
2016-11-04 03:28:23 +00:00
|
|
|
if (!this.index) {
|
|
|
|
this.index = this.$parent.$children.indexOf(this) + 1 + '';
|
2016-07-27 06:15:02 +00:00
|
|
|
}
|
2016-11-23 02:47:12 +00:00
|
|
|
if (this.$parent.panes) {
|
|
|
|
this.$parent.panes.push(this);
|
|
|
|
}
|
2016-07-27 06:15:02 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
computed: {
|
|
|
|
show() {
|
2016-11-04 03:28:23 +00:00
|
|
|
return this.$parent.currentName === this.index;
|
2016-07-27 06:15:02 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2016-09-28 07:20:50 +00:00
|
|
|
destroyed() {
|
2016-11-23 02:47:12 +00:00
|
|
|
if (this.$el && this.$el.parentNode) {
|
2016-11-08 16:01:56 +00:00
|
|
|
this.$el.parentNode.removeChild(this.$el);
|
2016-11-04 09:07:49 +00:00
|
|
|
}
|
2016-11-23 02:47:12 +00:00
|
|
|
const panes = this.$parent.panes;
|
|
|
|
if (panes) {
|
|
|
|
panes.splice(this, panes.indexOf(this));
|
|
|
|
}
|
2016-09-28 07:20:50 +00:00
|
|
|
},
|
|
|
|
|
2016-07-27 06:15:02 +00:00
|
|
|
watch: {
|
2016-08-12 08:18:36 +00:00
|
|
|
name: {
|
|
|
|
immediate: true,
|
|
|
|
handler(val) {
|
2016-11-04 03:28:23 +00:00
|
|
|
this.index = val;
|
2016-08-12 08:18:36 +00:00
|
|
|
}
|
|
|
|
},
|
2016-11-23 02:47:12 +00:00
|
|
|
closable(val) {
|
|
|
|
this.isClosable = val;
|
|
|
|
},
|
2016-08-12 08:18:36 +00:00
|
|
|
'$parent.currentName'(newValue, oldValue) {
|
2016-11-04 03:28:23 +00:00
|
|
|
if (this.index === newValue) {
|
2016-07-27 06:15:02 +00:00
|
|
|
this.transition = newValue > oldValue ? 'slideInRight' : 'slideInLeft';
|
|
|
|
}
|
2016-11-04 03:28:23 +00:00
|
|
|
if (this.index === oldValue) {
|
2016-07-27 06:15:02 +00:00
|
|
|
this.transition = oldValue > newValue ? 'slideInRight' : 'slideInLeft';
|
|
|
|
}
|
2016-12-14 17:53:31 +00:00
|
|
|
},
|
|
|
|
label() {
|
|
|
|
this.$parent.$forceUpdate();
|
2016-07-27 06:15:02 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
</script>
|
|
|
|
<template>
|
2016-09-30 11:44:46 +00:00
|
|
|
<div class="el-tab-pane" v-show="show && $slots.default">
|
2016-07-27 06:15:02 +00:00
|
|
|
<slot></slot>
|
|
|
|
</div>
|
|
|
|
</template>
|