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
In many Vue projects, global components will be defined using `app.component()`, followed by `app.mount('#app')`to target a container element in the body of every page.
5
+
多くの Vue プロジェクトでは、 グローバルコンポーネントは `app.mount('#app')`の後に各ページの body においてコンテナ要素のターゲットすることに続いて、`app.component()` を使用して定義されています。
6
6
7
-
This can work very well for small to medium-sized projects, where JavaScript is only used to enhance certain views. In more complex projects however, or when your frontend is entirely driven by JavaScript, these disadvantages become apparent:
Here's an example of a file we'll call `Hello.vue`:
16
+
こちらが `Hello.vue` と呼ばれたファイルの例です:
17
17
18
18
<ahref="https://codepen.io/team/Vue/pen/3de13b5cd0133df4ecf307b6cf2c5f94"target="_blank"rel="noopener noreferrer"><imgsrc="/images/sfc.png"width="403"alt="Single-file component example (click for code as text)"style="display: block; margin: 15pxauto; max-width: 100%"></a>
<ahref="https://codesandbox.io/s/vue-single-file-component-with-pre-processors-mr3ik?file=/src/App.vue"target="_blank"rel="noopener noreferrer"><imgsrc="/images/sfc-with-preprocessors.png"width="563"alt="Single-file component with pre-processors example (click for code as text)"style="display: block; margin: 15pxauto; max-width: 100%"></a>
29
29
30
-
These specific languages are only examples. You could as easily use TypeScript, SCSS, PostCSS, or whatever other preprocessors that help you be productive. If using Webpack with `vue-loader`, it also has first-class support for CSS Modules.
One important thing to note is that **separation of concerns is not equal to separation of file types.**In modern UI development, we have found that instead of dividing the codebase into three huge layers that interweave with one another, it makes much more sense to divide them into loosely-coupled components and compose them. Inside a component, its template, logic and styles are inherently coupled, and collocating them actually makes the component more cohesive and maintainable.
Even if you don't like the idea of Single-File Components, you can still leverage its hot-reloading and pre-compilation features by separating your JavaScript and CSS into separate files:
@@ -44,24 +44,25 @@ Even if you don't like the idea of Single-File Components, you can still leverag
44
44
<stylesrc="./my-component.css"></style>
45
45
```
46
46
47
-
## Getting Started
47
+
## はじめる
48
48
49
-
### Example Sandbox
49
+
### サンドボックスの例
50
50
51
-
If you want to dive right in and start playing with single-file components, check out [this simple todo app](https://codesandbox.io/s/vue-todo-list-app-with-single-file-component-vzkl3?file=/src/App.vue) on CodeSandbox.
51
+
すぐに触ってそして単一ファイルコンポーネントを試したい方は、CodeSandBox 上の [この単純な todo アプリケーション](https://codesandbox.io/s/vue-todo-list-app-with-single-file-component-vzkl3?file=/src/App.vue)
52
+
をチェックしてみてください。
52
53
53
-
### For Users New to Module Build Systems in JavaScript
54
+
### JavaScript でモジュールビルドシステムが初めてなユーザ向け
54
55
55
-
With `.vue`components, we're entering the realm of advanced JavaScript applications. That means learning to use a few additional tools if you haven't already:
-**Node Package Manager (NPM)**: Read the [Getting Started guide](https://docs.npmjs.com/packages-and-modules/getting-packages-from-the-registry)section about how to get packages from the registry.
58
+
-**Node Package Manager (NPM)**: レジストリからパッケージを取得する方法については[Getting Started guide](https://docs.npmjs.com/packages-and-modules/getting-packages-from-the-registry)のセクションを読んでください。
58
59
59
-
-**Modern JavaScript with ES2015/16**: Read through Babel's [Learn ES2015 guide](https://babeljs.io/docs/en/learn). You don't have to memorize every feature right now, but keep this page as a reference you can come back to.
After you've taken a day to dive into these resources, we recommend checking out [Vue CLI](https://cli.vuejs.org/). Follow the instructions and you should have a Vue project with `.vue`components, ES2015, webpack and hot-reloading in no time!
The CLI takes care of most of the tooling configurations for you, but also allows fine-grained customization through its own [config options](https://cli.vuejs.org/config/).
In case you prefer setting up your own build setup from scratch, you will need to manually configure webpack with[vue-loader](https://vue-loader.vuejs.org). To learn more about webpack itself, check out [their official docs](https://webpack.js.org/configuration/) and [webpack learning academy](https://webpack.academy/p/the-core-concepts).
0 commit comments