網站首頁 編程語言 正文
如圖,三個步驟中的所有表單,要一起提交;
那么每個步驟的表單信息 要拼接在一起 ,最后一起提交
對象拼接
this.form = Object.assign(this.form,data);
home.vue
<template>
<div class="home">
<el-steps :active="active" finish-status="success">
<el-step title="步驟 1"></el-step>
<el-step title="步驟 2"></el-step>
<el-step title="步驟 3"></el-step>
</el-steps>
<Step1 @getnext='getnext' v-if='active==1' />
<Step2 v-if='active==2' @getnext='getnext'/>
<Step3 v-if='active==3' :lastform='form'/>
</div>
</template>
<script>
import Step1 from "./components/step1.vue";
import Step2 from "./components/step2.vue";
import Step3 from "./components/step3.vue";
export default {
name: "Home",
components: {
Step1,
Step2,
Step3,
},
data() {
return {
active: 1,
form:{}
};
},
methods: {
getnext(ac, data) {
console.log(ac, data, "0000");
this.active = ac;
if(data) {
this.form = Object.assign(this.form,data);
console.log(this.form,'this.form')
}
},
},
};
</script>
step.vue
<template>
<div>
<el-form :model="ruleForm" ref="ruleForm" label-width="100px" class="demo-ruleForm">
<el-form-item label="活動名稱" prop="name">
<el-input v-model="ruleForm.name" tabindex='1'></el-input>
</el-form-item>
<el-form-item label="性別" prop="gender">
<el-input v-model="ruleForm.gender" tabindex='-1'></el-input>
</el-form-item>
<el-form-item label="abc" prop="abc">
<el-input v-model="ruleForm.abc" tabindex='2'></el-input>
</el-form-item>
<el-form-item>
<el-button @click="next">下一步</el-button>
</el-form-item>
</el-form>
</div>
</template>
<script>
export default {
name: "AdminBetterStep1",
data() {
return {
ruleForm: {
name: "",
gender: "",
abc: "",
},
rules: {},
};
},
mounted() {},
methods: {
next() {
this.$emit('getnext',2,this.ruleForm)
}
},
};
</script>
<style lang="scss" scoped>
</style>
step2.vue
<template>
<div>
<el-form :model="ruleForm" ref="ruleForm" label-width="100px" class="demo-ruleForm">
<el-form-item label="活動名稱" prop="ddd">
<el-input v-model="ruleForm.ddd" tabindex='1'></el-input>
</el-form-item>
<el-form-item label="性別" prop="eee">
<el-input v-model="ruleForm.eee" tabindex='-1'></el-input>
</el-form-item>
<el-form-item>
<el-button @click="next">下一步</el-button>
</el-form-item>
</el-form>
</div>
</template>
<script>
export default {
name: 'AdminBetterStep2',
data() {
return {
ruleForm: {
ddd: "",
eee: "",
},
rules: {},
};
},
mounted() {
},
methods: {
next() {
this.$emit('getnext',3,this.ruleForm)
}
},
};
</script>
<style lang="scss" scoped>
</style>
step3.vue
<template>
<div>
1:{{lastform.name}}<br />
2:{{lastform.gender}}<br />
3:{{lastform.abc}}<br />
4:{{lastform.ddd}}<br />
5:{{lastform.eee}}<br />
</div>
</template>
<script>
export default {
name: "AdminBetterStep3",
props: {
lastform: {
type: Object,
},
},
data() {
return {};
},
mounted() {},
methods: {},
};
</script>
<style lang="scss" scoped>
</style>
補充:多個對象拼接使用Object.assign(form1.form2)
也可使用 {...obj1,...obj2}
原文鏈接:https://blog.csdn.net/weixin_44707050/article/details/122453893
相關推薦
- 2023-04-07 解決jest處理es模塊示例詳解_React
- 2023-06-13 C語言中函數返回值不一致問題_C 語言
- 2022-07-16 gitee設置ssh key
- 2022-04-08 c++11中std::move函數的使用_C 語言
- 2022-10-27 python使用pika庫調用rabbitmq參數使用詳情_python
- 2022-08-10 淺談pandas關于查看庫或依賴庫版本的API原理_python
- 2022-05-20 Windows10或者11 使用Administrator登錄
- 2022-07-09 基于fluttertoast實現封裝彈框提示工具類_Android
- 最近更新
-
- window11 系統安裝 yarn
- 超詳細win安裝深度學習環境2025年最新版(
- Linux 中運行的top命令 怎么退出?
- MySQL 中decimal 的用法? 存儲小
- get 、set 、toString 方法的使
- @Resource和 @Autowired注解
- Java基礎操作-- 運算符,流程控制 Flo
- 1. Int 和Integer 的區別,Jav
- spring @retryable不生效的一種
- Spring Security之認證信息的處理
- Spring Security之認證過濾器
- Spring Security概述快速入門
- Spring Security之配置體系
- 【SpringBoot】SpringCache
- Spring Security之基于方法配置權
- redisson分布式鎖中waittime的設
- maven:解決release錯誤:Artif
- restTemplate使用總結
- Spring Security之安全異常處理
- MybatisPlus優雅實現加密?
- Spring ioc容器與Bean的生命周期。
- 【探索SpringCloud】服務發現-Nac
- Spring Security之基于HttpR
- Redis 底層數據結構-簡單動態字符串(SD
- arthas操作spring被代理目標對象命令
- Spring中的單例模式應用詳解
- 聊聊消息隊列,發送消息的4種方式
- bootspring第三方資源配置管理
- GIT同步修改后的遠程分支