Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/vue.js/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Vue.js 单击Vue js中的按钮后,如何将部分内容复制到表单中_Vue.js - Fatal编程技术网

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>

我现在正在使用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> 
  <!-- 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,,
}
},
};