diff --git a/dev-example/App.vue b/dev-example/App.vue
index 1eebeb2..c709c72 100644
--- a/dev-example/App.vue
+++ b/dev-example/App.vue
@@ -7,19 +7,22 @@
class="card">
- My first tab content
- My second tab content
- Yuhuuu! This seems pretty damn simple
+
+
+
diff --git a/dev-example/main.js b/dev-example/main.js
index 2efeb59..00e25c7 100644
--- a/dev-example/main.js
+++ b/dev-example/main.js
@@ -1,14 +1,29 @@
// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue'
+import VueRouter from 'vue-router'
import App from './App.vue'
import FormWizard from '../src/index'
+const First = { template: 'First page
' }
+const Second = { template: 'Second page
' }
+const Third = { template: 'Third page
' }
+
+const router = new VueRouter({
+ mode: 'history',
+ routes: [
+ { path: '/first', component: First },
+ { path: '/second', component: Second },
+ { path: '/third', component: Third }
+ ]
+})
+Vue.use(VueRouter)
Vue.use(FormWizard)
Vue.config.productionTip = false
/* eslint-disable no-new */
new Vue({
+ router,
el: '#app',
template: '',
components: {App}
diff --git a/package.json b/package.json
index 2c0540a..08d61bf 100644
--- a/package.json
+++ b/package.json
@@ -25,7 +25,6 @@
"url": "https://github.com/cristijora/vue-form-wizard"
},
"devDependencies": {
- "vue": "^2.2.2",
"autoprefixer": "^6.7.2",
"babel-core": "^6.22.1",
"babel-eslint": "^7.1.1",
@@ -84,7 +83,9 @@
"sinon-chai": "^2.8.0",
"stats-webpack-plugin": "^0.6.0",
"url-loader": "^0.5.8",
+ "vue": "^2.2.2",
"vue-loader": "^11.1.4",
+ "vue-router": "^2.5.1",
"vue-style-loader": "^2.0.0",
"vue-template-compiler": "^2.2.4",
"webpack": "^2.2.1",
diff --git a/src/components/FormWizard.vue b/src/components/FormWizard.vue
index f6de490..6a27e99 100644
--- a/src/components/FormWizard.vue
+++ b/src/components/FormWizard.vue
@@ -253,8 +253,14 @@
}
this.activeTabIndex = newIndex
this.checkStep()
+ this.tryChangeRoute(newTab)
return true
},
+ tryChangeRoute (tab) {
+ if (this.$router && tab.route) {
+ this.$router.push(tab.route)
+ }
+ },
checkStep () {
if (this.activeTabIndex === this.tabCount - 1) {
this.isLastStep = true
@@ -300,12 +306,14 @@
if (this.tabs.length > 0 && this.startIndex === 0) {
let firstTab = this.tabs[this.activeTabIndex]
firstTab.active = true
+ this.tryChangeRoute(firstTab)
}
if (this.startIndex < this.tabs.length) {
let tabToActivate = this.tabs[this.startIndex]
this.activeTabIndex = this.startIndex
tabToActivate.active = true
this.maxStep = this.startIndex
+ this.tryChangeRoute(this.tabs[this.startIndex])
} else {
console.warn(`Prop startIndex set to ${this.startIndex} is greater than the number of tabs - ${this.tabs.length}. Make sure that the starting index is less than the number of tabs registered`)
}
diff --git a/src/components/TabContent.vue b/src/components/TabContent.vue
index 4c74002..d306759 100644
--- a/src/components/TabContent.vue
+++ b/src/components/TabContent.vue
@@ -26,6 +26,9 @@
*/
beforeChange: {
type: Function
+ },
+ route: {
+ type: [String, Object]
}
},
data () {