CFormSubmit 是表单提交按钮组件,用于在表单中提供提交按钮。组件支持固定在底部显示,并可以通过插槽自定义按钮文本。
import { CFormSubmit } from '@components/forms/form';
fixed
(Boolean,可选):是否固定在底部显示,默认为 false<template>
<CForm :form="form" :onFinish="handleFinish">
<CFormItem name="username" label="用户名" required>
<CInput type="text" placeholder="请输入用户名" />
</CFormItem>
<CFormSubmit>提交</CFormSubmit>
</CForm>
</template>
<script>
import { CForm, CFormItem, CFormSubmit } from '@components/forms/form';
import { CInput } from '@components/forms/input';
export default {
components: {
CForm,
CFormItem,
CFormSubmit,
CInput
},
data() {
return {
form: {
username: ''
}
};
},
methods: {
handleFinish() {
console.log('表单提交成功', this.form);
}
}
};
</script>
<CFormSubmit :fixed="true">确认提交</CFormSubmit>
<CFormSubmit>
<view class="custom-btn-text">保存并继续</view>
</CFormSubmit>
form-type="submit"
属性,可以自动触发表单提交fixed
为 true 时,按钮会固定在页面底部显示,适用于长表单