Skip to content

Commit 09ae816

Browse files
committed
fix: use method shorthands and switch indexOf to includes
vuejs/docs@6730d26
1 parent 37e0109 commit 09ae816

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/guide/component-props.md

+5-5
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ data() {
145145
```js
146146
props: ['size'],
147147
computed: {
148-
normalizedSize: function () {
148+
normalizedSize() {
149149
return this.size.trim().toLowerCase()
150150
}
151151
}
@@ -183,22 +183,22 @@ app.component('my-component', {
183183
type: Object,
184184
// オブジェクトもしくは配列のデフォルト値は
185185
// 必ずファクトリ関数(それを生み出すための関数)を返す必要があります。
186-
default: function() {
186+
default() {
187187
return { message: 'hello' }
188188
}
189189
},
190190
// カスタムバリデーション関数
191191
propF: {
192-
validator: function(value) {
192+
validator(value) {
193193
// プロパティの値は、必ずいずれかの文字列でなければならない
194-
return ['success', 'warning', 'danger'].indexOf(value) !== -1
194+
return ['success', 'warning', 'danger'].includes(value)
195195
}
196196
},
197197
// デフォルト値つきの関数型
198198
propG: {
199199
type: Function,
200200
// オブジェクトや配列のデフォルトとは異なり、これはファクトリ関数ではありません。これは、デフォルト値としての関数を取り扱います。
201-
default: function() {
201+
default() {
202202
return 'Default function'
203203
}
204204
}

0 commit comments

Comments
 (0)