diff --git a/src/api/custom-elements.md b/src/api/custom-elements.md index 4f0952f96..b41585866 100644 --- a/src/api/custom-elements.md +++ b/src/api/custom-elements.md @@ -1,11 +1,10 @@ - -# Custom Elements API {#custom-elements-api} +# 自定义元素 API {#custom-elements-api} ## defineCustomElement() {#definecustomelement} -This method accepts the same argument as [`defineComponent`](#definecomponent), but instead returns a native [Custom Element](https://developer.mozilla.org/en-US/docs/Web/Web_Components/Using_custom_elements) class constructor. +此方法接受的参数与 [`defineComponent`](#definecomponent) 相同,但返回一个原生[自定义元素](https://developer.mozilla.org/zh-CN/docs/Web/Web_Components/Using_custom_elements)类构造函数。 -- **Type** +- **类型** ```ts function defineCustomElement( @@ -20,28 +19,28 @@ This method accepts the same argument as [`defineComponent`](#definecomponent), interface CustomElementsOptions { styles?: string[] - // the following options are 3.5+ + // 以下选项在 3.5+ 版本中支持 configureApp?: (app: App) => void shadowRoot?: boolean nonce?: string } ``` - > Type is simplified for readability. + > 类型为简化版,便于阅读。 -- **Details** +- **详情** - In addition to normal component options, `defineCustomElement()` also supports a number of options that are custom-elements-specific: + 除了常规的组件选项,`defineCustomElement()` 还支持一系列特定于自定义元素的选项: - - **`styles`**: an array of inlined CSS strings for providing CSS that should be injected into the element's shadow root. + - **`styles`**:一个内联 CSS 字符串数组,用于提供应注入元素 shadow root 的 CSS。 - - **`configureApp`** : a function that can be used to configure the Vue app instance for the custom element. + - **`configureApp`** :一个函数,可用于配置自定义元素的 Vue 应用实例。 - - **`shadowRoot`** : `boolean`, defaults to `true`. Set to `false` to render the custom element without a shadow root. This means `