2016-07-27 06:15:02 +00:00
|
|
|
<script>
|
|
|
|
module.exports = {
|
|
|
|
name: 'el-tab-pane',
|
|
|
|
|
|
|
|
props: {
|
|
|
|
label: {
|
|
|
|
type: String,
|
|
|
|
required: true
|
|
|
|
},
|
2016-08-12 08:18:36 +00:00
|
|
|
name: String
|
2016-07-27 06:15:02 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
counter: 0,
|
|
|
|
transition: '',
|
|
|
|
paneStyle: {
|
|
|
|
position: 'relative'
|
2016-08-12 08:18:36 +00:00
|
|
|
},
|
|
|
|
key: ''
|
2016-07-27 06:15:02 +00:00
|
|
|
};
|
|
|
|
},
|
|
|
|
|
|
|
|
created() {
|
|
|
|
if (!this.key) {
|
|
|
|
this.key = this.$parent.$children.indexOf(this) + 1 + '';
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
computed: {
|
|
|
|
show() {
|
2016-08-12 08:18:36 +00:00
|
|
|
return this.$parent.currentName === this.key;
|
2016-07-27 06:15:02 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
watch: {
|
2016-08-12 08:18:36 +00:00
|
|
|
name: {
|
|
|
|
immediate: true,
|
|
|
|
handler(val) {
|
|
|
|
this.key = val;
|
|
|
|
}
|
|
|
|
},
|
|
|
|
'$parent.currentName'(newValue, oldValue) {
|
2016-07-27 06:15:02 +00:00
|
|
|
if (this.key === newValue) {
|
|
|
|
this.transition = newValue > oldValue ? 'slideInRight' : 'slideInLeft';
|
|
|
|
}
|
|
|
|
if (this.key === oldValue) {
|
|
|
|
this.transition = oldValue > newValue ? 'slideInRight' : 'slideInLeft';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<template>
|
2016-09-21 10:45:29 +00:00
|
|
|
<div class="el-tab-pane" v-if="show && $slots.default">
|
2016-07-27 06:15:02 +00:00
|
|
|
<slot></slot>
|
|
|
|
</div>
|
|
|
|
</template>
|