You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The name you give a component may depend on where you intend to use it. When using a component directly in the DOM (as opposed to in a string template or [single-file component](../guide/single-file-component.html), we strongly recommend following the [W3C rules](https://html.spec.whatwg.org/multipage/custom-elements.html#valid-custom-element-name)for custom tag names:
When defining a component with PascalCase, you can use either case when referencing its custom element. That means both `<my-component-name>`and`<MyComponentName>`are acceptable. Note, however, that only kebab-case names are valid directly in the DOM (i.e. non-string templates).
These components are **globally registered**for the application. That means they can be used in the template of any component instance within this application:
Global registration often isn't ideal. For example, if you're using a build system like Webpack, globally registering all components means that even if you stop using a component, it could still be included in your final build. This unnecessarily increases the amount of JavaScript your users have to download.
In these cases, you can define your components as plain JavaScript objects:
94
+
以下のケースでは、プレーン JavaScript としてコンポーネントを定義することができます:
95
95
96
96
```js
97
97
constComponentA= {
@@ -105,7 +105,7 @@ const ComponentC = {
105
105
}
106
106
```
107
107
108
-
Then define the components you'd like to use in a `components`option:
108
+
次に `components`オプション内に使用したいコンポーネントを定義します:
109
109
110
110
```js
111
111
constapp=Vue.createApp({
@@ -116,9 +116,9 @@ const app = Vue.createApp({
116
116
})
117
117
```
118
118
119
-
For each property in the `components`object, the key will be the name of the custom element, while the value will contain the options object for the component.
Note that **locally registered components are _not_ also available in subcomponents**. For example, if you wanted `ComponentA`to be available in `ComponentB`, you'd have to use:
Note that in ES2015+, placing a variable name like `ComponentA`inside an object is shorthand for `ComponentA: ComponentA`, meaning the name of the variable is both:
-the custom element name to use in the template, and
152
-
-the name of the variable containing the component options
151
+
-テンプレート内で使用されるカスタム要素名
152
+
-コンポーネントオプションを含む変数の名前
153
153
154
-
## Module Systems
154
+
## モジュールシステム
155
155
156
-
If you're not using a module system with `import`/`require`, you can probably skip this section for now. If you are, we have some special instructions and tips just for you.
If you're still here, then it's likely you're using a module system, such as with Babel and Webpack. In these cases, we recommend creating a `components`directory, with each component in its own file.
Then you'll need to import each component you'd like to use, before you locally register it. For example, in a hypothetical `ComponentB.js`or`ComponentB.vue`file:
0 commit comments