Skip to content

Commit af2a34c

Browse files
authored
Docs > Migration from Vue 2 の細かな差分 (#359)
* fix: update link to <script setup> RFC vuejs/docs@f0b4e44#diff-f33c8ecc58b0894342124aa3a90c3fcde6f0ba09588ee6b20b1fe0056e378137 * docs: 📝 clarify async components for Vue Router vuejs/docs@4c7c1e5#diff-f33c8ecc58b0894342124aa3a90c3fcde6f0ba09588ee6b20b1fe0056e378137 * chore: switch javascript code blocks to js vuejs/docs@5753b78#diff-f33c8ecc58b0894342124aa3a90c3fcde6f0ba09588ee6b20b1fe0056e378137
1 parent 41c7287 commit af2a34c

File tree

5 files changed

+18
-14
lines changed

5 files changed

+18
-14
lines changed

src/guide/migration/async-components.md

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,14 @@ badges:
2020
以前、非同期コンポーネントは Promise を返す関数としてコンポーネントを定義することで、このように簡単に作成されました:
2121

2222
```js
23-
const asyncPage = () => import('./NextPage.vue')
23+
const asyncModal = () => import('./Modal.vue')
2424
```
2525

2626
または、オプション付きのさらに高度なコンポーネント構文として:
2727

2828
```js
29-
const asyncPage = {
30-
component: () => import('./NextPage.vue'),
29+
const asyncModal = {
30+
component: () => import('./Modal.vue'),
3131
delay: 200,
3232
timeout: 3000,
3333
error: ErrorComponent,
@@ -45,25 +45,29 @@ import ErrorComponent from './components/ErrorComponent.vue'
4545
import LoadingComponent from './components/LoadingComponent.vue'
4646

4747
// オプションなしの非同期コンポーネント
48-
const asyncPage = defineAsyncComponent(() => import('./NextPage.vue'))
48+
const asyncModal = defineAsyncComponent(() => import('./Modal.vue'))
4949

5050
// オプション付きの非同期コンポーネント
51-
const asyncPageWithOptions = defineAsyncComponent({
52-
loader: () => import('./NextPage.vue'),
51+
const asyncModalWithOptions = defineAsyncComponent({
52+
loader: () => import('./Modal.vue'),
5353
delay: 200,
5454
timeout: 3000,
5555
errorComponent: ErrorComponent,
5656
loadingComponent: LoadingComponent
5757
})
5858
```
5959

60+
::: tip NOTE
61+
Vue Router は *遅延読み込み* と呼ばれるルートコンポーネントを非同期に読み込む似たような仕組みをサポートしています。似てはいますが、この機能は Vue の非同期コンポーネントのサポートとは異なります。 Vue Router でルートコンポーネントを構成するときは、 `defineAsyncComponent`**使用しない** 必要があります。これについては、 Vue Router のドキュメントの [ルートの遅延読み込み](https://next.router.vuejs.org/guide/advanced/lazy-loading.html) で詳しく説明されています。
62+
:::
63+
6064
2.x からなされたもう一つの変更は、直接コンポーネント定義を提供できないことを正確に伝えるために `component` オプションの名前が `loader` に替わったことです。
6165

6266
```js{4}
6367
import { defineAsyncComponent } from 'vue'
6468
65-
const asyncPageWithOptions = defineAsyncComponent({
66-
loader: () => import('./NextPage.vue'),
69+
const asyncModalWithOptions = defineAsyncComponent({
70+
loader: () => import('./Modal.vue'),
6771
delay: 200,
6872
timeout: 3000,
6973
errorComponent: ErrorComponent,

src/guide/migration/custom-directives.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,15 +86,15 @@ app.directive('highlight', {
8686

8787
Vue 2 では、コンポーネントインスタンスは `vnode` 引数を使ってアクセスする必要がありました。
8888

89-
```javascript
89+
```js
9090
bind(el, binding, vnode) {
9191
const vm = vnode.context
9292
}
9393
```
9494

9595
Vue 3 では、インスタンスは `binding` の一部になりました。
9696

97-
```javascript
97+
```js
9898
mounted(el, binding, vnode) {
9999
const vm = binding.instance
100100
}

src/guide/migration/filters.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ badges:
7979

8080
その代わり、 [globalProperties](../../api/application-config.html#globalproperties) によって、すべてのコンポーネントがグローバルフィルタを利用できるようにすることができます:
8181

82-
```javascript
82+
```js
8383
// main.js
8484
const app = createApp(App)
8585

src/guide/migration/introduction.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ Vue 3 で注目すべきいくつかの新機能の次のとおりです。
4646
- [Fragments](/guide/migration/fragments.html)
4747
- [Emits Component Option](/guide/component-custom-events.html)
4848
- カスタムレンダラを作るための [`@vue/runtime-core``createRenderer` API](https://github.com/vuejs/vue-next/tree/master/packages/runtime-core)
49-
- [SFC での Composition API の Syntax Sugar (`<script setup>`)](https://github.com/vuejs/rfcs/blob/sfc-improvements/active-rfcs/0000-sfc-script-setup.md) <Badge text="experimental" type="warning" />
49+
- [SFC での Composition API の Syntax Sugar (`<script setup>`)](https://github.com/vuejs/rfcs/blob/script-setup-2/active-rfcs/0000-script-setup.md) <Badge text="experimental" type="warning" />
5050
- [SFC でのステートドリブンな CSS Variables (`<style>``v-bind`)](https://github.com/vuejs/rfcs/blob/style-vars-2/active-rfcs/0000-sfc-style-variables.md) <Badge text="experimental" type="warning" />
5151
- [SFC での `<style scoped>` は、グローバルルールまたはスロットされたコンテンツのみを対象とするルールを含めることができるようになった](https://github.com/vuejs/rfcs/blob/master/active-rfcs/0023-scoped-styles-changes.md)
5252
- [Suspense](/guide/migration/suspense.html) <Badge text="experimental" type="warning" />

src/guide/migration/listeners-removed.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ badges:
1010

1111
`$listeners` オブジェクトは Vue 3 で削除されました。イベントリスナは `$attrs` の一部になりました。
1212

13-
```javascript
13+
```js
1414
{
1515
text: 'this is an attribute',
1616
onClose: () => console.log('close Event triggered')
@@ -54,7 +54,7 @@ export default {
5454

5555
もしこのコンポーネントが `id` 属性と `v-on:close` リスナを受け取った場合、 `$attrs` オブジェクトは次のようになります:
5656

57-
```javascript
57+
```js
5858
{
5959
id: 'my-input',
6060
onClose: () => console.log('close Event triggered')

0 commit comments

Comments
 (0)