Skip to content

Commit 374dfc9

Browse files
authored
Migration > Mount Changes の翻訳を追従 (#255)
* fead: add migration guide > mount changes * docs: translate migration guide > mount api changes * feat: link to translated pages
1 parent 8a38285 commit 374dfc9

File tree

2 files changed

+97
-3
lines changed

2 files changed

+97
-3
lines changed

src/.vuepress/config.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -194,19 +194,19 @@ const sidebar = {
194194
'/guide/migration/key-attribute',
195195
'/guide/migration/keycode-modifiers',
196196
'/guide/migration/listeners-removed',
197-
// '/guide/migration/mount-changes',
197+
'/guide/migration/mount-changes',
198198
// '/guide/migration/props-data',
199199
'/guide/migration/props-default-this',
200200
'/guide/migration/render-function-api',
201201
'/guide/migration/slots-unification',
202202
'/guide/migration/suspense',
203203
'/guide/migration/transition',
204-
// '/guide/migration/transition-group',
204+
'/guide/migration/transition-group',
205205
'/guide/migration/v-on-native-modifier-removed',
206206
'/guide/migration/v-model',
207207
'/guide/migration/v-if-v-for',
208208
'/guide/migration/v-bind',
209-
// '/guide/migration/vnode-lifecycle-events',
209+
'/guide/migration/vnode-lifecycle-events',
210210
'/guide/migration/watch'
211211
]
212212
},

src/guide/migration/mount-changes.md

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
---
2+
title: 'マウント API の変更'
3+
badges:
4+
- breaking
5+
---
6+
7+
# 要素を置換しないアプリケーションのマウント <MigrationBadges :badges="$frontmatter.badges" />
8+
9+
## 概要
10+
11+
Vue 2.x では、 `template` を持つアプリケーションをマウントすると、レンダリングされたコンテンツがマウント先の要素を置き換えます。 Vue 3.x では、レンダリングされたアプリケーションは、子要素として追加され、要素の `innerHTML` を置き換えます。
12+
13+
## 2.x での構文
14+
15+
Vue 2.x では、 HTML 要素セレクタを `new Vue()` または `$mount` に渡します:
16+
17+
```js
18+
new Vue({
19+
el: '#app',
20+
data() {
21+
return {
22+
message: 'Hello Vue!'
23+
}
24+
},
25+
template: `
26+
<div id="rendered">{{ message }}</div>
27+
`
28+
})
29+
30+
// または
31+
const app = new Vue({
32+
data() {
33+
return {
34+
message: 'Hello Vue!'
35+
}
36+
},
37+
template: `
38+
<div id="rendered">{{ message }}</div>
39+
`
40+
})
41+
42+
app.$mount('#app')
43+
```
44+
45+
このアプリケーションを渡されたセレクタ (ここでは `id="app"`) を持つ `div` のあるページにマウントした場合:
46+
47+
```html
48+
<body>
49+
<div id="app">
50+
Some app content
51+
</div>
52+
</body>
53+
```
54+
55+
レンダリングされた結果は、上記の `div` がレンダリングされたアプリケーションのコンテンツと置き換えられます:
56+
57+
```html
58+
<body>
59+
<div id="rendered">Hello Vue!</div>
60+
</body>
61+
```
62+
63+
## 3.x での構文
64+
65+
Vue 3.x では、アプリケーションをマウントすると、レンダリングされたコンテンツが `mount` に渡した要素の `innerHTML` を置き換えます:
66+
67+
```js
68+
const app = Vue.createApp({
69+
data() {
70+
return {
71+
message: 'Hello Vue!'
72+
}
73+
},
74+
template: `
75+
<div id="rendered">{{ message }}</div>
76+
`
77+
})
78+
79+
app.mount('#app')
80+
```
81+
82+
このアプリケーションを `id="app"` を持つ `div` のあるページにマウントすると、このようになります:
83+
84+
```html
85+
<body>
86+
<div id="app" data-v-app="">
87+
<div id="rendered">Hello Vue!</div>
88+
</div>
89+
</body>
90+
```
91+
92+
## 参照
93+
94+
- [`mount` API](/api/application-api.html#mount)

0 commit comments

Comments
 (0)