Comments (8)
我也有相同的问题,我有两个提交,一个是预览订单,一个是提交订单,需求没法做。
from ant-design-mini.
我们正在重构当前的表单,这个问题我这边临时解决下
from ant-design-mini.
我们正在重构当前的表单,这个问题我这边临时解决下
我尝试了一下 onTap会在 htmlType="submit"之前执行,所以我给绑定了一个点击事件设置一个标记,并在submit事件中进行判断,然后执行不同的逻辑,我不确定onTap事件是否总是可以在submit之前执行,但这临时的解决了我的问题。
// buy.js
Page({
data: {
// 提交是否是预览订单
previewOrderFlag: false
},
// 表单提交事件
orderSubmit(e) {
if(this.data.previewOrderFlag){
this.previewOrder();
return;
}
// 这里是提交的逻辑
},
previewOrder(){
if(this.data.previewOrderFlag){
// 预览订单逻辑
this.setData({
previewOrderFlag: false
})
}else {
this.setData({
previewOrderFlag: true
})
}
}
}
from ant-design-mini.
我们正在重构当前的表单,这个问题我这边临时解决下
我不是一个专业的前端工程师,您知道onTap和 submit是同步还是异步执行吗?我想知道这样做是否会有问题。
from ant-design-mini.
onTap 是会立刻执行,submit 会触发form的validate校验等,你这样写是ok的,如果你还担心时序问题,你可以给handlesubmit 采用 setTimeout 异步执行
from ant-design-mini.
from ant-design-mini.
1.0 使用方式:
<form-input
label="用户名"
name="account"
ref="handleForm1"
/>
<form-input
label="密码"
name="password"
password
ref="handleForm1"
/>
<button onTap="submitForm1">提交表单1</button>
<form-input
label="用户名"
name="account"
ref="handleForm2"
/>
<form-input
label="密码"
name="password"
ref="handleForm1"
/>
<button onTap="submitForm1">提交表单2</button>
import Form from 'antd-mini/es/Form/form';
Page({
form1: new Form(), // 表单1
form2: new Form(), // 表单2
handleForm1(ref) {
this.form1.addItem(ref);
},
handleForm2(ref) {
this.form2.addItem(ref);
},
async submitForm1() {
const values = await this.form1.submit();
console.log(values);
},
async submitForm2() {
const values = await this.form2.submit();
console.log(values);
},
});
from ant-design-mini.
https://ant-design-mini.antgroup.com/components/form#%E5%A4%9A%E4%B8%AA%E8%A1%A8%E5%8D%95 多个表单示例
from ant-design-mini.
Related Issues (20)
- Ant Design Mini 中的日历组件报错 HOT 8
- form-textarea HOT 1
- 在iOS真机上,如果把canvas放到modal中,获取到的node是个null HOT 1
- input、textarea组件属性maxlength在支付宝中maxlength,组件中maxLength,导致不生效 HOT 4
- form-textarea autoHeight 样式 HOT 1
- swiper-item的内容无法撑开 HOT 5
- 元素input没有onChange事件,所以ant-input的onChange没有用 HOT 2
- swipe-action 右边边缘会有按钮的颜色 HOT 3
- 希望优化一下步骤条的内容,可以展示图片
- 图片预览有吗 HOT 2
- 更新一下贡献指南 HOT 2
- Popup组件中的getContentStyle方法失效bug HOT 4
- formItem的label能放出一个slot吗 HOT 1
- 【BUG】tabBar的change事件获取不到tabItem的对象?? HOT 1
- 表单自定义如何被触发onchange? HOT 6
- 最新版本Icon组件样式不起作用 HOT 1
- NoticeBar组件visible属性 HOT 1
- 钉钉小程序使用range-picker组件失效 HOT 3
- antd-mini 升级到2.0后 selector组建 minSelectedCount 与 multiple属性不能同时生效 HOT 2
- popup、picker等弹窗组件在二层弹窗会出现样式问题
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ant-design-mini.