Skip to content

Commit 5c92fcc

Browse files
oohirakazupon
authored andcommitted
Apply v2.6 updates in original English text (#1473)
* cherry-pick vuejs/v2.vuejs.org@3cd3e69
1 parent cb1a43f commit 5c92fcc

File tree

5 files changed

+606
-108
lines changed

5 files changed

+606
-108
lines changed

src/v2/api/index.md

Lines changed: 141 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
title: API
33
type: api
4-
updated: 2019-01-29
4+
updated: 2019-02-11
55
---
66

77
## グローバル設定
@@ -85,6 +85,8 @@ updated: 2019-01-29
8585
8686
> 2.4.0 以降では、このフックは Vue のカスタムイベントハンドラ内部で投げられたエラーもキャプチャします。
8787
88+
> In 2.6.0+, this hook also captures errors thrown inside `v-on` DOM listeners. In addition, if any of the covered hooks or handlers returns a Promise chain (e.g. async functions), the error from that Promise chain will also be handled.
89+
8890
> エラー追跡サービスの [Sentry](https://sentry.io/for/vue/)[Bugsnag](https://docs.bugsnag.com/platforms/browsers/vue/) はこのオプションを使用して公式の統合を提供しています。
8991
9092
### warnHandler
@@ -404,6 +406,35 @@ updated: 2019-01-29
404406

405407
- **参照:** [描画関数](../guide/render-function.html)
406408

409+
### Vue.observable( object )
410+
411+
> New in 2.6.0+
412+
413+
- **Arguments:**
414+
- `{Object} object`
415+
416+
- **Usage:**
417+
418+
Make an object reactive. Internally, Vue uses this on the object returned by the `data` function.
419+
420+
The returned object can be used directly inside [render functions](../guide/render-function.html) and [computed properties](../guide/computed.html), and will trigger appropriate updates when mutated. It can also be used as a minimal, cross-component state store for simple scenarios:
421+
422+
``` js
423+
const state = Vue.observable({ count: 0 })
424+
425+
const Demo = {
426+
render(h) {
427+
return h('button', {
428+
on: { click: () => { state.count++ }}
429+
}, `count is: ${state.count}`)
430+
}
431+
}
432+
```
433+
434+
<p class="tip">In Vue 2.x, `Vue.observable` directly mutates the object passed to it, so that it is equivalent to the object returned, as [demonstrated here](../guide/instance.html#Data-and-Methods). In Vue 3.x, a reactive proxy will be returned instead, leaving the original object non-reactive if mutated directly. Therefore, for future compatibility, we recommend always working with the object returned by `Vue.observable`, rather than the object originally passed to it.</p>
435+
436+
- **See also:** [Reactivity in Depth](../guide/reactivity.html)
437+
407438
### Vue.version
408439

409440
- **詳細:** インストールされている Vue のバージョンを文字列として提供します。これはコミュニティのプラグインやコンポーネントで特に役立ち、異なるバージョンで違う戦略を使うことができます。
@@ -1393,7 +1424,7 @@ updated: 2019-01-29
13931424

13941425
> 2.1.0 から新規
13951426
1396-
- **型:** `{ [name: string]: props => VNode | Array<VNode> }`
1427+
- **型:** `{ [name: string]: props => Array<VNode> | undefined }`
13971428

13981429
- **読み込みのみ**
13991430

@@ -1403,6 +1434,12 @@ updated: 2019-01-29
14031434

14041435
`vm.$scopedSlots` にアクセスする際に、[描画関数](../guide/render-function.html) でコンポーネントを書くときに最も便利です。
14051436

1437+
**Note:** since 2.6.0+, there are two notable changes to this property:
1438+
1439+
1. Scoped slot functions are now guaranteed to return an array of VNodes, unless the return value is invalid, in which case the function will return `undefined`.
1440+
1441+
2. All `$slots` are now also exposed on `$scopedSlots` as functions. If you work with render functions, it is now recommended to always access slots via `$scopedSlots`, whether they currently use a scope or not. This will not only make future refactors to add a scope simpler, but also ease your eventual migration to Vue 3, where all slots will be functions.
1442+
14061443
- **See also:**
14071444
- [`<slot>` コンポーネント](#slot-1)
14081445
- [スコープ付きスロット](../guide/components.html#スコープ付きスロット)
@@ -1950,7 +1987,7 @@ updated: 2019-01-29
19501987

19511988
### v-for
19521989

1953-
- **要求事項:** `Array | Object | number | string`
1990+
- **要求事項:** `Array | Object | number | string | Iterable (since 2.6)`
19541991

19551992
- **使用方法:**
19561993

@@ -1978,6 +2015,8 @@ updated: 2019-01-29
19782015
</div>
19792016
```
19802017

2018+
In 2.6+, `v-for` can also work on values that implement the [Iterable Protocol](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols#The_iterable_protocol), including native `Map` and `Set`. However, it should be noted that Vue 2.x currently does not support reactivity on `Map` and `Set` values, so cannot automatically detect changes.
2019+
19812020
<p class="tip">`v-if` といっしょに使用されるとき、`v-for` は `v-if` より優先度が高くなります。詳細については<a href="../guide/list.html#v-for-と-v-if">リストレンダリングのガイド</a>を参照してください。</p>
19822021

19832022
`v-for` の詳細な使用方法は下記にリンクしたガイドセクション内で説明しています。
@@ -2023,12 +2062,18 @@ updated: 2019-01-29
20232062
<!-- メソッドハンドラ -->
20242063
<button v-on:click="doThis"></button>
20252064

2065+
<!-- dynamic event (2.6.0+) -->
2066+
<button v-on:[event]="doThis"></button>
2067+
20262068
<!-- インラインステートメント -->
20272069
<button v-on:click="doThat('hello', $event)"></button>
20282070

20292071
<!-- 省略記法 -->
20302072
<button @click="doThis"></button>
20312073

2074+
<!-- shorthand dynamic event (2.6.0+) -->
2075+
<button @[event]="doThis"></button>
2076+
20322077
<!-- イベント伝播の停止 -->
20332078
<button @click.stop="doThis"></button>
20342079

@@ -2100,9 +2145,15 @@ updated: 2019-01-29
21002145
<!-- 属性を束縛 -->
21012146
<img v-bind:src="imageSrc">
21022147

2148+
<!-- dynamic attribute name (2.6.0+) -->
2149+
<button v-bind:[key]="value"></button>
2150+
21032151
<!-- 省略記法 -->
21042152
<img :src="imageSrc">
21052153

2154+
<!-- shorthand dynamic attribute name (2.6.0+) -->
2155+
<button :[key]="value"></button>
2156+
21062157
<!-- インライン文字列連結 -->
21072158
<img :src="'/path/to/images/' + fileName">
21082159

@@ -2167,6 +2218,59 @@ updated: 2019-01-29
21672218
- [フォーム入力バインディング](../guide/forms.html)
21682219
- [コンポーネント - カスタムイベントを使用してフォーム入力コンポーネント](../guide/components.html#カスタムイベントを使用したフォーム入力コンポーネント)
21692220

2221+
### v-slot
2222+
2223+
- **Shorthand:** `#`
2224+
2225+
- **Expects:** JavaScript expression that is valid in a function argument position (supports destructuring in [supported environments](../guide/components-slots.html#Slot-Props-Destructuring)). Optional - only needed if expecting props to be passed to the slot.
2226+
2227+
- **Argument:** slot name (optional, defaults to `default`)
2228+
2229+
- **Limited to:**
2230+
- `<template>`
2231+
- [components](../guide/components-slots.html#Abbreviated-Syntax-for-Lone-Default-Slots) (for a lone default slot with props)
2232+
2233+
- **Usage:**
2234+
2235+
Denote named slots or slots that expect to receive props.
2236+
2237+
- **Example:**
2238+
2239+
```html
2240+
<!-- Named slots -->
2241+
<base-layout>
2242+
<template v-slot:header>
2243+
Header content
2244+
</template>
2245+
2246+
Default slot content
2247+
2248+
<template v-slot:footer>
2249+
Footer content
2250+
</template>
2251+
</base-layout>
2252+
2253+
<!-- Named slot that receives props -->
2254+
<infinite-scroll>
2255+
<template v-slot:item="slotProps">
2256+
<div class="item">
2257+
{{ slotProps.item.text }}
2258+
</div>
2259+
</template>
2260+
</infinite-scroll>
2261+
2262+
<!-- Default slot that receive props, with destructuring -->
2263+
<mouse-position v-slot="{ x, y }">
2264+
Mouse position: {{ x }}, {{ y }}
2265+
</mouse-position>
2266+
```
2267+
2268+
For more details, see the links below.
2269+
2270+
- **See also:**
2271+
- [Components - Slots](../guide/components-slots.html)
2272+
- [RFC-0001](https://github.com/vuejs/rfcs/blob/master/active-rfcs/0001-new-slot-syntax.md)
2273+
21702274
### v-pre
21712275

21722276
- **式を受け付けません**
@@ -2286,38 +2390,6 @@ updated: 2019-01-29
22862390

22872391
- **参照:** [子コンポーネントの参照](../guide/components.html#子コンポーネントの参照)
22882392

2289-
### slot
2290-
2291-
- **要求事項:** `string`
2292-
2293-
名前付き slot のコンテンツが属しているというのを示すために、コンテンツを子コンポーネントに挿入するために使用されます。
2294-
2295-
詳しい使い方については、以下のリンク先のガイドを参照してください。
2296-
2297-
- **参照:** [名前付きスロット](../guide/components.html#名前付きスロット)
2298-
2299-
### slot-scope
2300-
2301-
> 2.5.0 から新規
2302-
2303-
- **要求事項:** `function argument expression`
2304-
2305-
- **使用方法:**
2306-
2307-
要素またはコンポーネントをスコープ付きスロットとして示すときに使用します。属性の値は、関数シグネチャの引数位置に表示できる有効な JavaScript 式が必要です。これは、式で ES2015 destructuring (分割代入)を使用できる環境をサポートすることを意味します。2.5.0以降で [`scope`](#scope-置き換え)の代わりとして提供されています。
2308-
2309-
この属性は動的なバインディングはサポートしません。
2310-
2311-
- **参照:** [スコープ付きスロット](../guide/components.html#スコープ付きスロット)
2312-
2313-
### scope <sup>置き換え</sup>
2314-
2315-
スコープ付きスロットとして `<template>` 要素を表すのに使われ、2.5.0以降では [`slot-scope`](#slot-scope)に置き換えられます。
2316-
2317-
- **使用方法:**
2318-
2319-
[`<slot-scope>`](#slot-scope)と同じですが、`scope`は `<template>` 要素に対してのみ使用できます。
2320-
23212393
### is
23222394

23232395
- **要求事項:** `string | Object (コンポーネントオプションのオブジェクト)`
@@ -2342,6 +2414,40 @@ updated: 2019-01-29
23422414
- [動的コンポーネント](../guide/components.html#動的コンポーネント)
23432415
- [DOM-テンプレート解析の注意事項](../guide/components.html#DOM-テンプレート解析の注意事項)
23442416

2417+
### slot <sup style="color:#c92222">deprecated</sup>
2418+
2419+
**Prefer [v-slot](#v-slot) in 2.6.0+.**
2420+
2421+
- **Expects:** `string`
2422+
2423+
Used on content inserted into child components to indicate which named slot the content belongs to.
2424+
2425+
- **See also:** [Named Slots with `slot`](../guide/components.html#Named-Slots-with-slot)
2426+
2427+
### slot-scope <sup style="color:#c92222">deprecated</sup>
2428+
2429+
**Prefer [v-slot](#v-slot) in 2.6.0+.**
2430+
2431+
- **Expects:** `function argument expression`
2432+
2433+
- **Usage:**
2434+
2435+
Used to denote an element or component as a scoped slot. The attribute's value should be a valid JavaScript expression that can appear in the argument position of a function signature. This means in supported environments you can also use ES2015 destructuring in the expression. Serves as a replacement for [`scope`](#scope-replaced) in 2.5.0+.
2436+
2437+
This attribute does not support dynamic binding.
2438+
2439+
- **See also:** [Scoped Slots with `slot-scope`](../guide/components.html#Scoped-Slots-with-slot-scope)
2440+
2441+
### scope <sup style="color:#c92222">removed</sup>
2442+
2443+
**Replaced by [slot-scope](#slot-scope) in 2.5.0+. Prefer [v-slot](#v-slot) in 2.6.0+.**
2444+
2445+
Used to denote a `<template>` element as a scoped slot.
2446+
2447+
- **Usage:**
2448+
2449+
Same as [`slot-scope`](#slot-scope) except that `scope` can only be used on `<template>` elements.
2450+
23452451
## 組み込みコンポーネント
23462452

23472453
### component

0 commit comments

Comments
 (0)