Vue.js 单击Vue js中的按钮后,如何将部分内容复制到表单中
我现在正在使用Vue js,我正在尝试复制模板中的一些代码。因为我不知道它需要多少形式,所以它必须是灵活的 我的模板代码Vue.js 单击Vue js中的按钮后,如何将部分内容复制到表单中,vue.js,Vue.js,我现在正在使用Vue js,我正在尝试复制模板中的一些代码。因为我不知道它需要多少形式,所以它必须是灵活的 我的模板代码 <form @submit="duplicated"> <b-form-input id="name" v-model="name" type="text" required/> ... other codes needs to copy <b-button type="submit">Save</b-button>
<form @submit="duplicated">
<b-form-input id="name" v-model="name" type="text" required/>
... other codes needs to copy
<b-button type="submit">Save</b-button>
<!-- after clicking the button, the website should show two forms -->
</form>
... 其他代码需要复制
拯救
您可以在数据中存储变量,并在表单中使用v-for
<form v-for="(form,index) in numberofForms" :key="index"
@submit.prevent = "numberofForms++" >
<b-form-input id="name" v-model="name" type="text" required/>
... other codes needs to copy
<b-button type="submit">Save</b-button>
</form>
export default {
...
data() {
return {
numberofForms: 1,
}
},
};
... 其他代码需要复制
拯救
导出默认值{
...
数据(){
返回{
表格数目:1,,
}
},
};