Skip to content

docs: update web-components.md NOTE code block #2556

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 11, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 6 additions & 8 deletions src/guide/extras/web-components.md
Original file line number Diff line number Diff line change
Expand Up @@ -306,9 +306,9 @@ declare module 'vue' {

Vue で構築されていないカスタム要素の SFC テンプレートで型チェックを有効にする推奨の方法をご紹介します。

> [!Note]
> この方法は、カスタム要素を作成する際に使用するフレームワークによって異なる場合があります。

:::tip Note
この方法は、カスタム要素を作成する際に使用するフレームワークによって異なる場合があります。
:::

いくつかの JS プロパティとイベントが定義されたカスタム要素があり、それが `some-lib` というライブラリーに同梱されているとします:

Expand Down Expand Up @@ -389,11 +389,9 @@ type VueEmit<T extends EventMap> = EmitFn<{
}>
```

> [!Note]
> 私たちは `$props` と `$emit` を非推奨としました。カスタム要素の `ref` を取得した際に、これらのプロパティを使用したくなる誘惑にかられないようにするためです。これらのプロパティはカスタム要素に関しては型チェックのみに使用されるためです。これらのプロパティは実際にはカスタム要素のインスタンスには存在しません。



:::tip Note
私たちは `$props` と `$emit` を非推奨としました。カスタム要素の `ref` を取得した際に、これらのプロパティを使用したくなる誘惑にかられないようにするためです。これらのプロパティはカスタム要素に関しては型チェックのみに使用されるためです。これらのプロパティは実際にはカスタム要素のインスタンスには存在しません。
:::

型ヘルパーを使用して、Vue テンプレートで型チェックのために公開すべき JS プロパティを選択できます:

Expand Down