# Props
Para definir propriedades para os componentes:
<template>
<div id="propNumber">
<p>{{ propString }}</p>
<p>{{ propSimples }}</p>
</div>
</template>
<script>
const ComponenteUm = () => import('@/components/ComponenteUm')
export default {
name: 'App',
data () {
return {
}
},
props: {
propSimples: String,
propObjSimples: Object,
propString: {
type: String,
required: true
},
propNumber: {
type: Number
},
propComValidacao: {
type: String,
validator: function (value) {
return ['small', 'large', 'overview'].indexOf(value) !== -1
}
},
propComDefaultValor: {
type: String,
default: ''
},
propBoolean: {
type: Boolean,
validator: function (value) {
return [true, false].indexOf(value) !== -1
}
},
propArray: {
type: Array,
validator: function (value) {
return value
}
},
propMultiTipos: {
type: [String, Array, Object, Number]
},
}
}
</script>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
← Components Computed →