ts: Property ‘resetFields‘ does not exist on type ‘Ref

ts: Property ‘resetFields’ does not exist on type 'Ref

Background: ts + vue3 + element plus
checks the rules according to the official document of element plus

// before 
import type {
    
     FormInstance } from 'element-plus'
const menuRef = ref<FormInstance>()
function reset() {
    
    
  form.value = initFormData();
   if (!menuRef) return
   menuRef.resetFields()
}
// after 
import type {
    
     FormInstance } from 'element-plus'
const menuRef = ref<FormInstance>()
function reset() {
    
    
  form.value = initFormData();
   if (!menuRef) return
   // ref变量需要使用value
   menuRef.value?.resetFields()
}

Guess you like

Origin blog.csdn.net/qubes/article/details/130821260