You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何在vue-form-wizard的第二步内容区添加返回上一步按钮

Solution for Adding Custom Previous Button in vue-form-wizard Step Content

Got it, the issue with your current code is that previousTab isn't a method available in your component's scope—vue-form-wizard handles step navigation through its own internal methods, which you need to access via a component reference. Here's how to fix this in your StepForm.vue:

Step 1: Add a ref to the vue-form-wizard component

First, assign a ref attribute to the root <vue-form-wizard> element so you can access its instance methods:

<template>
  <vue-form-wizard ref="formWizard" @on-complete="onComplete">
    <!-- Your form steps will go here -->
  </vue-form-wizard>
</template>

Step 2: Add the custom previous button in your second tab content

In the second <tab-content>, update your button to call the wizard's built-in previous() method via the ref you just added:

<tab-content title="second tab">
  <!-- Your step-specific content goes here -->
  <button @click="$refs.formWizard.previous()">Take me back to the previous tab</button>
</tab-content>

Optional: Wrap the logic in a component method (for extra flexibility)

If you want to add pre-navigation logic (like form validation checks) before moving back, you can define a custom method in your component script:

<script>
export default {
  methods: {
    navigateToPreviousStep() {
      // Add any checks or actions here (e.g., validate form fields first)
      this.$refs.formWizard.previous();
    }
  }
}
</script>

Then update the button to use this method:

<button @click="navigateToPreviousStep()">Take me back to the previous tab</button>

This works because vue-form-wizard exposes previous() and next() methods for programmatic step control. By accessing the component instance through $refs, you can trigger these methods directly from your step content instead of relying on the default footer buttons.

内容的提问来源于stack exchange,提问作者deeej

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.09 09:52:27