vue-custom-form/public/components/form.js
2023-08-02 23:48:08 -04:00

45 lines
651 B
JavaScript

import Step from "./step.js";
const Form =
{
props: ["name", "steps", "submit"],
components: {
Step
},
setup(props)
{
const curr = Vue.ref(0);
function next() {
curr.value < props.steps.length - 1 ?
curr.value += 1 :
props.submit();
}
return { curr, next };
},
template: `
<div class="form">
<Step v-bind="steps[curr]" />
<button class="next-button form-button button" @click="next">Next</button>
</div>
`
}
export default Form;
/*
So we store the results of the form inside the templete itself.
Is this really a good idea?
Why not just have a mapping that we fill out as the form progresses?
*/