回答編集履歴
1
誤字修正
answer
CHANGED
@@ -1,21 +1,1 @@
|
|
1
|
-
Vue.js では、匿名関数の中では `this` は、使えません。そのため、以下のように書き換えてください。
|
2
|
-
|
3
|
-
```
|
4
|
-
// NG
|
5
|
-
export const getters = {
|
6
|
-
isSmall: () =>
|
7
|
-
this.$vuetify.breakpoint.width < this.$vuetify.breakpoint.thresholds.sm,
|
8
|
-
}
|
9
|
-
```
|
10
|
-
```js
|
11
|
-
// OK
|
12
|
-
export const getters = {
|
13
|
-
|
1
|
+
削除 誤回答のため
|
14
|
-
return this.$vuetify.breakpoint.width < this.$vuetify.breakpoint.thresholds.sm
|
15
|
-
},
|
16
|
-
}
|
17
|
-
```
|
18
|
-
|
19
|
-
正確に言えば使えない訳ではないです。以下の記事の「違い1: thisの指すもの」を、ご確認ください。
|
20
|
-
|
21
|
-
* [JavaScript: 通常の関数とアロー関数の違いは「書き方だけ」ではない。異なる性質が10個ほどある。 - Qiita](https://qiita.com/suin/items/a44825d253d023e31e4d#%E9%81%95%E3%81%841-this%E3%81%AE%E6%8C%87%E3%81%99%E3%82%82%E3%81%AE)
|