Skip to content

Commit 2a8a1df

Browse files
author
Amon Keishima
committed
docs: translate teleport.md
1 parent 8b16dda commit 2a8a1df

File tree

1 file changed

+17
-17
lines changed

1 file changed

+17
-17
lines changed

src/guide/teleport.md

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
# Teleport
22

3-
Vue encourages us to build our UIs by encapsulating UI and related behavior into components. We can nest them inside one another to build a tree that makes up an application UI.
3+
Vue は私たちに、UI やそれに関連する挙動をコンポーネントにして、カプセル化することで UI を作り上げることを勧めています。私たちはそれらを互いに入れ子にして、アプリケーションを構成するツリーを作ることができます。
44

5-
However, sometimes a part of a component's template belongs to this component logically, while from a technical point of view, it would be preferable to move this part of the template somewhere else in the DOM, outside of the Vue app.
5+
しかしながら、コンポーネントのテンプレートの一部が、論理的にこのコンポーネントに属している場合もありますが、技術的な観点では、テンプレートのこの部分を Vue アプリの外や、DOM 内の別の場所に移動させることが望ましいこともあります。
66

7-
A common scenario for this is creating a component that includes a full-screen modal. In most cases, you'd want the modal's logic to live within the component, but the positioning of the modal quickly becomes difficult to solve through CSS, or requires a change in component composition.
7+
これの一般的なシナリオは、フルスクリーンのモーダルを含むコンポーネントです。多くの場合、モーダルのロジックはコンポーネント内に残したいと思うでしょうが、モーダルの配置はすぐに CSS で解決するのが難しくなったり、コンポーネントの構成を変更する必要が出てくるでしょう。
88

9-
Consider the following HTML structure.
9+
以下のような HTML 構造を考えてみましょう。
1010

1111
```html
1212
<body>
@@ -19,9 +19,9 @@ Consider the following HTML structure.
1919
</body>
2020
```
2121

22-
Let's take a look at `modal-button`.
22+
modal-button` について見てみましょう。
2323

24-
The component will have a `button` element to trigger the opening of the modal, and a `div` element with a class of `.modal`, which will contain the modal's content and a button to self-close.
24+
コンポーネントはモーダルを開くための `button` 要素を持っており、さらに `.modal` クラスを持った `div` 要素があります。これはモーダルのコンテンツを表示して、自身を閉じるためのボタンを持っている要素です。
2525

2626
```js
2727
const app = Vue.createApp({});
@@ -49,11 +49,11 @@ app.component('modal-button', {
4949
})
5050
```
5151

52-
When using this component inside the initial HTML structure, we can see a problem - the modal is being rendered inside the deeply nested `div` and the `position: absolute` of the modal takes the parent relatively positioned `div` as reference.
52+
このコンポーネントを最初の HTML 構造の中で使うときに、問題が見えてきます。モーダルは深く入れ子になった `div` の中にレンダリングされており、モーダルの `position: absolute` は、相対的に位置する親の `div` を参照として使用します。
5353

54-
Teleport provides a clean way to allow us to control under which parent in our DOM we want a piece of HTML to be rendered, without having to resort to global state or splitting this into two components.
54+
Teleport は、グローバルステートに頼ったり、2つのコンポーネントに分割しなくても、HTML の一部を DOM のどの親の下でレンダリングするかを制御するための、きれいな方法を提供します。
5555

56-
Let's modify our `modal-button` to use `<teleport>` and tell Vue "**teleport** this HTML **to** the "**body**" tag".
56+
`<teleport>` を使って、Vue にこの HTML を "**body**" タグに "**teleport**" させるよう、`modal-button` を変更しましょう。
5757

5858
```js
5959
app.component('modal-button', {
@@ -82,7 +82,7 @@ app.component('modal-button', {
8282
})
8383
```
8484

85-
As a result, once we click the button to open the modal, Vue will correctly render the modal's content as a child of the `body` tag.
85+
その結果、ボタンをクリックしてモーダルを開くと、Vue はモーダルのコンテンツを `body` タグの子として正しくレンダリングします。
8686

8787
<p class="codepen" data-height="300" data-theme-id="39028" data-default-tab="js,result" data-user="Vue" data-slug-hash="gOPNvjR" data-preview="true" data-editable="true" style="height: 300px; box-sizing: border-box; display: flex; align-items: center; justify-content: center; border: 2px solid; margin: 1em 0; padding: 1em;" data-pen-title="Vue 3 Teleport">
8888
<span>See the Pen <a href="https://codepen.io/team/Vue/pen/gOPNvjR">
@@ -91,9 +91,9 @@ As a result, once we click the button to open the modal, Vue will correctly rend
9191
</p>
9292
<script async src="https://static.codepen.io/assets/embed/ei.js"></script>
9393

94-
## Using with Vue components
94+
## Vue コンポーネントと使う
9595

96-
If `<teleport>` contains a Vue component, it will remain a logical child component of the `<teleport>`'s parent:
96+
もし `<teleport>` Vue コンポーネントを含む場合、それは`<teleport>` の親の、論理的な子コンポーネントのままになります。
9797

9898
```js
9999
const app = Vue.createApp({
@@ -120,13 +120,13 @@ app.component('child-component', {
120120
})
121121
```
122122

123-
In this case, even when `child-component` is rendered in the different place, it will remain a child of `parent-component` and will receive a `name` prop from it.
123+
この場合、 `child-component` が別の場所にレンダリングされたとしても、`parent-component` の子のままとなるため、`name` prop を受け取ります。
124124

125-
This also means that injections from a parent component work as expected, and that the child component will be nested below the parent component in the Vue Devtools, instead of being placed where the actual content moved to.
125+
これは、親コンポーネントからの注入が期待通りに動作し、Vue Devtools 上では実際のコンテンツが移動した場所に配置されるのではなく、親コンポーネントの下に配置されることを意味します。
126126

127-
## Using multiple teleports on the same target
127+
## 複数の teleport のターゲットを同じにして使う
128128

129-
A common use case scenario would be a reusable `<Modal>` component of which there might be multiple instances active at the same time. For this kind of scenario, multiple `<teleport>` components can mount their content to the same target element. The order will be a simple append - later mounts will be located after earlier ones within the target element.
129+
一般的なユースケースのシナリオは、再利用可能な `<Modal>` コンポーネントで、同時に複数のインスタンスがアクティブになっている状態かもしれません。このようなシナリオの場合、複数の `<teleport>` は、同じターゲット要素に対してそれぞれのコンテンツをマウントすることができます。
130130

131131
```html
132132
<teleport to="#modals">
@@ -143,4 +143,4 @@ A common use case scenario would be a reusable `<Modal>` component of which ther
143143
</div>
144144
```
145145

146-
You can check `<teleport>` component options in the [API reference](../api/built-in-components.html#teleport)
146+
`<teleport>` コンポーネントのオプションは [API リファレンス](../api/built-in-components.html#teleport) で確認できます。

0 commit comments

Comments
 (0)