Browse Source

feat: alias $attrs to $props when component has no declared props

Evan You 7 năm trước cách đây
mục cha
commit
3a7bbecb22
1 tập tin đã thay đổi với 3 bổ sung0 xóa
  1. 3 0
      packages/core/src/componentProps.ts

+ 3 - 0
packages/core/src/componentProps.ts

@@ -84,6 +84,9 @@ export function resolveProps(
         validateProp(key, unwrap(rawData[key]), opt, isAbsent)
       }
     }
+  } else {
+    // if component has no declared props, $attrs === $props
+    attrs = props
   }
   return { props, attrs }
 }