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
A `*.vue`file is a custom file format that uses HTML-like syntax to describe a Vue component. Each `*.vue`file consists of three types of top-level language blocks: `<template>`, `<script>`, and`<style>`, and optionally additional custom blocks:
10
+
`.vue`文件是一个自定义的文件类型,用类 HTML 语法描述一个 Vue 组件。每个 `.vue`文件包含三种类型的顶级语言块 `<template>`、`<script>` 和`<style>`,还允许添加可选的自定义块:
11
11
12
12
```vue
13
13
<template>
@@ -35,82 +35,82 @@ export default {
35
35
</custom1>
36
36
```
37
37
38
-
`vue-loader`will parse the file, extract each language block, pipe them through other loaders if necessary, and finally assemble them back into an ES Module whose default export is a Vue.js component options object.
38
+
`vue-loader`会解析文件,提取每个语言块,如有必要会通过其它 loader 处理,最后将他们组装成一个 ES Module,它的默认导出是一个 Vue.js 组件选项的对象。
39
39
40
-
`vue-loader`supports using non-default languages, such as CSS pre-processors and compile-to-HTML template languages, by specifying the `lang`attribute for a language block. For example, you can use Sass for the style of your component like this:
40
+
`vue-loader`支持使用非默认语言,比如 CSS 预处理器,预编译的 HTML 模版语言,通过设置语言块的 `lang`属性。例如,你可以像下面这样使用 Sass 语法编写样式:
41
41
42
42
```vue
43
43
<style lang="sass">
44
44
/* write Sass! */
45
45
</style>
46
46
```
47
47
48
-
More details can be found in [Using Pre-Processors](./pre-processors.md).
48
+
更多细节可以在[使用预处理器](./pre-processors.md)中找到。
49
49
50
-
## Language Blocks
50
+
## 语言块
51
51
52
-
### Template
52
+
### 模板
53
53
54
-
-Each `*.vue`file can contain at most one `<template>`block at a time.
54
+
-每个 `.vue`文件最多包含一个 `<template>`块。
55
55
56
-
-Contents will be extracted and passed on to `vue-template-compiler`and pre-compiled into JavaScript render functions, and finally injected into the exported component in the `<script>`section.
-Each `*.vue`file can contain at most one `<script>`block at a time.
60
+
-每个 `.vue`文件最多包含一个 `<script>`块。
61
61
62
-
-The script is executed as an ES Module.
62
+
-这个脚本会作为一个 ES Module 来执行。
63
63
64
-
-The **default export** should be a Vue.js [component options object](https://vuejs.org/v2/api/#Options-Data). Exporting an extended constructor created by `Vue.extend()`is also supported, but a plain object is preferred.
-Any webpack rules that match against `.js`files (or the extension specified by the `lang`attribute) will be applied to contents in the `<script>`block as well.
-A single `*.vue`file can contain multiple `<style>`tags.
72
+
-一个 `.vue`文件可以包含多个 `<style>`标签。
73
73
74
-
-A `<style>`tag can have `scoped`or`module`attributes (see [Scoped CSS](./scoped-css.md) and [CSS Modules](./css-modules.md)) to help encapsulate the styles to the current component. Multiple `<style>`tags with different encapsulation modes can be mixed in the same component.
-Any webpack rules that match against `.css`files (or the extension specified by the `lang`attribute) will be applied to contents in the `<style>`blocks as well.
Additional custom blocks can be included in a `*.vue`file for any project specific needs, for example a `<docs>`block. `vue-loader`will use the tag name to look up which webpack loaders should be applied to the contents of the section. The webpack loaders should be specified in the `loaders` section of `vue-loader` options.
Contributions for other editors/IDEs are highly appreciated! If you are not using any pre-processors in Vue components, you can also get decent syntax highlighting by treating `*.vue`files as HTML in your editor.
123
+
非常感谢其他编辑器/IDE 所做的贡献!如果在 Vue 组件中没有使用任何预处理器,你可以把 `.vue`文件当作 HTML 对待。
124
124
125
-
## Comments
126
-
127
-
Inside each block you shall use the comment syntax of the language being used (HTML, CSS, JavaScript, Jade, etc). For top-level comments, use HTML comment syntax: `<!-- comment contents here -->`
125
+
## 注释
128
126
127
+
在语言块中使用该语言块对应的注释语法 (HTML、CSS、JavaScript、Jade 等)。顶层注释使用 HTML 注释语法:`<!-- comment contents here -->`
0 commit comments