2
0
mirror of https://github.com/tenrok/vue-form-wizard.git synced 2026-06-17 23:10:32 +03:00

Use provide/inject to register tabs for layout flexibility

This commit is contained in:
cristijora
2017-11-22 18:59:05 +02:00
parent 9cf6ade15b
commit a8d1f6150f
4 changed files with 43 additions and 10 deletions
+6
View File
@@ -157,6 +157,12 @@
}
}
},
provide () {
return {
addTab: this.addTab,
removeTab: this.removeTab
}
},
data () {
return {
activeTabIndex: 0,
+3 -2
View File
@@ -38,6 +38,7 @@
default: () => {}
}
},
inject: ['addTab', 'removeTab'],
data () {
return {
active: false,
@@ -57,13 +58,13 @@
}
},
mounted () {
this.$parent.addTab(this)
this.addTab(this)
},
destroyed () {
if (this.$el && this.$el.parentNode) {
this.$el.parentNode.removeChild(this.$el)
}
this.$parent.removeTab(this)
this.removeTab(this)
}
}
</script>