Идея такая: есть компонент V-Stepper, он содержит несколько шагов. Я хотел бы запустить действие перехода к следующему шагу, когда метод validateDirectory завершится успешно (т. е. кнопка следующего шага не нажимается физически, но этот шаг вызывается программно).
Методы определяются примерно так:
methods: {
stepperPrev() {
this.$refs.stepperActions.prev()
},
stepperNext() {
this.$refs.stepperActions.next()
},
async validateDirectory() {
const response = await fetch(...)
this.stepperNext()
}
v-stepper-actions содержит: <v-stepper-actions ref = "stepperActions" @click:next = "next" @click:prev = "prev"></v-stepper-actions>
Однако при попытке добиться перехода к следующему степперному окну я получаю ошибку: this.$refs.stepperActions.next is not a function.
Также попробовал определить методы как:
stepperPrev(prev) {
prev()
},
stepperNext(next) {
next()
}
Это также не сработало.
Есть ли способ вызвать переход к следующему шагу? Кроме того, можно ли скрыть v-stepper-actions и при этом иметь возможность запускать действие программно?





Похоже, это работает отлично.
<template>
<v-app>
<v-container>
<button @click = "stepperPrev">previous</button>
<button @click = "stepperNext">next</button>
<v-stepper
ref = "stepperActions" <--- ⚠️ important
:items = "['Step 1', 'Step 2', 'Step 3']"
>
<template v-slot:item.1>
<v-card title = "Step One" flat>...</v-card>
</template>
<template v-slot:item.2>
<v-card title = "Step Two" flat>...</v-card>
</template>
<template v-slot:item.3>
<v-card title = "Step Three" flat>...</v-card>
</template>
</v-stepper>
</v-container>
</v-app>
</template>
<script>
export default {
methods: {
stepperPrev() {
this.$refs.stepperActions.prev()
},
stepperNext() {
this.$refs.stepperActions.next()
},
},
}
</script>
Вот детская площадка.
Главное, что вам нужно, это ref = "stepperActions" на самом v-stepper.