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
Copy file name to clipboardExpand all lines: src/guide/installation.md
+88-14
Original file line number
Diff line number
Diff line change
@@ -91,20 +91,47 @@ $ yarn
91
91
$ yarn dev
92
92
```
93
93
94
-
## Explanation of Different Builds
94
+
## Explanation of Different Builds 不同打包的解释
95
95
96
-
In the [`dist/` directory of the npm package](https://cdn.jsdelivr.net/npm/[email protected]/dist/) you will find many different builds of Vue.js. Here is an overview of which `dist` file should be used depending on the use-case.
96
+
In the [`dist/` directory of the npm package](https://cdn.jsdelivr.net/npm/[email protected]/dist/) you will find many different builds of Vue.js.
Here is an overview of which `dist` file should be used depending on the use-case.
100
+
以下是应该根据用例使用哪个“dist”文件的概述。
97
101
98
102
### From CDN or without a Bundler
103
+
从CDN或没有捆绑
99
104
100
105
#### `vue(.runtime).global(.prod).js`:
101
106
102
107
- For direct use via `<script src="...">` in the browser, exposes the Vue global.
108
+
-直接使用通过' <script src="…“>”在浏览器中,公开Vue全局变量。
109
+
110
+
111
+
103
112
- In-browser template compilation:
104
-
-`vue.global.js` is the "full" build that includes both the compiler and the runtime so it supports compiling templates on the fly.
105
-
-`vue.runtime.global.js` contains only the runtime and requires templates to be pre-compiled during a build step.
106
-
- Inlines all Vue core internal packages - i.e. it's a single file with no dependencies on other files. This means you must import everything from this file and this file only to ensure you are getting the same instance of code.
107
-
- Contains hard-coded prod/dev branches, and the prod build is pre-minified. Use the `*.prod.js` files for production.
113
+
-浏览器内模板编译:
114
+
115
+
-`vue.global.js` is the "full" build that includes both the compiler and the runtime so it supports compiling templates on the fly.
116
+
——“vue.global.js是“完整的”构建,包括编译器和运行时,所以它支持动态编译模板。
117
+
118
+
-`vue.runtime.global.js` contains only the runtime and requires templates to be pre-compiled during a build step.
- Inlines all Vue core internal packages - i.e. it's a single file with no dependencies on other files.
122
+
-内联所有Vue核心内部包-即,它是一个独立的文件,不依赖于其他文件。
123
+
124
+
This means you must import everything from this file and this file only to ensure you are getting the same instance of code.
125
+
这意味着您必须从这个文件和这个文件中导入所有内容,以确保获得相同的代码实例。
126
+
127
+
- Contains hard-coded prod/dev branches, and the prod build is pre-minified.
128
+
-包含硬编码的prod/dev分支,并且prod构建是预先缩小的。
129
+
130
+
Use the `*.prod.
131
+
使用‘* .prod。
132
+
133
+
js` files for production.
134
+
js的文件用于生产。
108
135
109
136
:::tip Note
110
137
Global builds are not [UMD](https://github.com/umdjs/umd) builds. They are built as [IIFEs](https://developer.mozilla.org/en-US/docs/Glossary/IIFE) and are only meant for direct use via `<script src="...">`.
@@ -113,34 +140,75 @@ Global builds are not [UMD](https://github.com/umdjs/umd) builds. They are built
113
140
#### vue(.runtime).esm-browser(.prod).js:
114
141
115
142
- For usage via native ES modules imports (in browser via `<script type="module">`.
143
+
-通过本地ES模块导入使用(在浏览器中通过`<script type="module"> `
144
+
116
145
- Shares the same runtime compilation, dependency inlining and hard-coded prod/dev behavior with the global build.
146
+
-与全局构建共享相同的运行时编译、依赖内联和硬编码的prod/dev行为。
117
147
118
148
### With a Bundler
119
149
120
150
#### vue(.runtime).esm-bundler.js:
121
151
122
152
- For use with bundlers like `webpack`, `rollup` and `parcel`.
123
-
- Leaves prod/dev branches with `process.env.NODE_ENV guards` (must be replaced by bundler)
153
+
-与“webpack”、“rollup”及“parcel”等捆扎程序一起使用。
154
+
155
+
- Leaves prod/dev branches with `process.env.
156
+
-将prod/dev分支设置为“process.env”。
157
+
158
+
NODE_ENV guards` (must be replaced by bundler)
159
+
NODE_ENV guard '(必须被bundler替换)
160
+
124
161
- Does not ship minified builds (to be done together with the rest of the code after bundling)
- Imported dependencies are also esm-bundler builds and will in turn import their dependencies (e.g. @vue/runtime-core imports @vue/reactivity)
127
-
- This means you **can** install/import these deps individually without ending up with different instances of these dependencies, but you must make sure they all resolve to the same version.
162
+
-不提供缩小的构建(在绑定后与其余代码一起完成)
163
+
164
+
- Imports dependencies (e.g.
165
+
-导入依赖项(例如:
166
+
167
+
`@vue/runtime-core`, `@vue/runtime-compiler`)
168
+
“@vue / runtime-core”、“@vue /运行时编译)
169
+
170
+
- Imported dependencies are also esm-bundler builds and will in turn import their dependencies (e.g. @vue/runtime-core imports @vue/reactivity)
- This means you **can** install/import these deps individually without ending up with different instances of these dependencies, but you must make sure they all resolve to the same version.
-`vue.runtime.esm-bundler.js`**(default)** is runtime only, and requires all templates to be pre-compiled. This is the default entry for bundlers (via module field in `package.json`) because when using a bundler templates are typically pre-compiled (e.g. in `*.vue` files).
130
-
-`vue.esm-bundler.js`: includes the runtime compiler. Use this if you are using a bundler but still want runtime template compilation (e.g. in-DOM templates or templates via inline JavaScript strings). You will need to configure your bundler to alias vue to this file.
177
+
-浏览器内模板编译:
178
+
179
+
-`vue.runtime.esm-bundler.js`**(default)** is runtime only, and requires all templates to be pre-compiled.
This is the default entry for bundlers (via module field in `package.json`) because when using a bundler templates are typically pre-compiled (e.g. in `*.
If you need to compile templates on the client (e.g. passing a string to the template option, or mounting to an element using its in-DOM HTML as the template), you will need the compiler and thus the full build:
vue` files are pre-compiled into JavaScript at build time.
229
+
vue的文件在构建时被预编译成JavaScript。
157
230
158
-
When using `vue-loader`, templates inside `*.vue` files are pre-compiled into JavaScript at build time. You don’t really need the compiler in the final bundle, and can therefore use the runtime-only build.
231
+
You don’t really need the compiler in the final bundle, and can therefore use the runtime-only build.
0 commit comments