Sometimes, we need to do something (Ajax, open modal, etc.) before the next step, can use two-way binding achieve. In example, we use setTimeout to simulation Ajax.
Code
<template> <divclass="single-example-with-hint-one-step"> <BaseButton@click="showStep = true" /> <MtStepv-if="showStep":modelValue="index"@update:modelValue="handleUpdateIndex" > <MtStepItem:stepItem="[ { selector: 'header', hint: { text: 'Click overlay and wait 2sec', position: 'bottom' }, }, ]" /> </MtStep> </div></template><scriptsetuplang="ts">import'mt-step/css'import { MtStep, MtStepItem } from'mt-step'import { ref } from'vue'constshowStep=ref(false)constindex=ref(0)consthandleUpdateIndex=async (newIndex:number) => {// do something, like AjaxawaitnewPromise((resolve) =>setTimeout(resolve, 2000))// after ajax, update index index.value = newIndex// edge case. if last step, close stepif (index.value >0) { showStep.value =false index.value =0 }}</script>