预期效果:点击确定 校验输入框内容

由于文档上写的比较模糊  

 经尝试结果代码应为

<template>
    <el-form :ref="formdata" :model="form">
        <el-radio-group v-model="form.isCache">
                <el-radio label="0">
                  缓存
                </el-radio>
                <el-radio label="1">
                  不缓存
                </el-radio>
              </el-radio-group>
         <el-button @click="submitForm">
            提交
          </el-button>
    </el-form>
</template>

<script>
import { defineComponent, toRefs, getCurrentInstance } from '@vue/runtime-core'

export default defineComponent({

  setup(){
    const { proxy } = getCurrentInstance()
    const dataMap=reactive({
        form:{},
        /** 提交按钮 */
        submitForm: function() {
            (proxy as any).$refs.formData.validate(valid => {
              if (valid) {
                //....
                } else {
               //....
                }
              }
            })
        }
    })
    
    retrun{
        ...toRefs(dataMap)
    }
    
  }
})
</script>

Logo

前往低代码交流专区

更多推荐