基于elelemt-ui封装一个表单

基于elelemt-ui封装一个表单_第1张图片子组件
searchForm





父组件

            html
            

父{{ searchFormModel }}

// 引入 import searchForm from './searchForm'; // 注册 components: { searchForm, }, setup() { const initData = reactive({ searchFormModel: { categoryIds: '666', ruleId: '', type: [], }, searchFromFields: [ { label: '活动名称', slot: 'categoryIds' }, { label: '活动区域', slot: 'ruleId' }, { label: '活动性质', slot: 'type' }, ], rules: { categoryIds: [ { required: true, message: '请输入用户名', trigger: 'blur' }, ], ruleId: [ { required: true, message: '请选择活动区域', trigger: 'change' }, ], type: [ { type: 'array', required: true, message: '请至少选择一个活动性质', trigger: 'change', }, ], }, searchFormRef: null, }); const onSearchFormSubmit = (form) => { console.log('表单提交了', form); }; const onSearchFormReset = () => { console.log('表单重置了'); // initData.searchFormRef.resetFields(); };

你可能感兴趣的:(ui,vue.js,javascript)