You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/rules/require-valid-default-prop.md
+52-53
Original file line number
Diff line number
Diff line change
@@ -2,65 +2,64 @@
2
2
3
3
-:gear: This rule is included in all of `"plugin:vue/essential"`, `"plugin:vue/strongly-recommended"` and `"plugin:vue/recommended"`.
4
4
5
-
This rule checks whether the default value of each prop is valid for the given type. It should report an error when default value for type `Array` or `Object` is not returned using function.
6
-
7
5
## :book: Rule Details
8
6
9
-
:-1: Examples of **incorrect** code for this rule:
10
-
11
-
```js
12
-
props: {
13
-
propA: {
14
-
type:String,
15
-
default: {}
16
-
},
17
-
propB: {
18
-
type:String,
19
-
default: []
20
-
},
21
-
propC: {
22
-
type:Object,
23
-
default: []
24
-
},
25
-
propD: {
26
-
type:Array,
27
-
default: []
28
-
},
29
-
propE: {
30
-
type:Object,
31
-
default: { message:'hello' }
32
-
}
33
-
}
34
-
```
35
-
36
-
:+1: Examples of **correct** code for this rule:
7
+
This rule checks whether the default value of each prop is valid for the given type. It should report an error when default value for type `Array` or `Object` is not returned using function.
37
8
38
-
```js
39
-
props: {
40
-
// basic type check (`null` means accept any type)
41
-
propA:Number,
42
-
// multiple possible types
43
-
propB: [String, Number],
44
-
// a number with default value
45
-
propD: {
46
-
type:Number,
47
-
default:100
48
-
},
49
-
// object/array defaults should be returned from a factory function
0 commit comments