From 190279ddb66036f73ac589d11ffa2413a55180cd Mon Sep 17 00:00:00 2001 From: Evan You Date: Tue, 15 Jan 2019 16:49:25 -0500 Subject: [PATCH 01/25] 2.6: document ESM browser build --- src/v2/guide/installation.md | 38 ++++++++++++++++++++++++++---------- 1 file changed, 28 insertions(+), 10 deletions(-) diff --git a/src/v2/guide/installation.md b/src/v2/guide/installation.md index d0f344adec..db4bc05c0f 100644 --- a/src/v2/guide/installation.md +++ b/src/v2/guide/installation.md @@ -27,17 +27,31 @@ Simply download and include with a script tag. `Vue` will be registered as a glo

Don't use the minified version during development. You will miss out on all the nice warnings for common mistakes!

-Development VersionWith full warnings and debug mode + Development VersionWith full warnings and debug mode -Production VersionWarnings stripped, {{gz_size}}KB min+gzip + Production VersionWarnings stripped, {{gz_size}}KB min+gzip
### CDN -We recommend linking to a specific version number that you can update manually: +For prototyping or learning purposes, you can use the latest version with: ``` html - + +``` + +For production, we recommend linking to a specific version number and build to avoid unexpected breakage from newer versions: + +``` html + +``` + +If you are using ES Modules, there is also an ES Modules compatible build: + +``` html + ``` You can browse the source of the NPM package at [cdn.jsdelivr.net/npm/vue](https://cdn.jsdelivr.net/npm/vue/). @@ -68,12 +82,12 @@ Vue provides an [official CLI](https://github.com/vuejs/vue-cli) for quickly sca In the [`dist/` directory of the NPM package](https://cdn.jsdelivr.net/npm/vue/dist/) you will find many different builds of Vue.js. Here's an overview of the difference between them: -| | UMD | CommonJS | ES Module | +| | UMD | CommonJS | ES Module (for bundlers) | ES Module (for browsers) | --- | --- | --- | --- | -| **Full** | vue.js | vue.common.js | vue.esm.js | -| **Runtime-only** | vue.runtime.js | vue.runtime.common.js | vue.runtime.esm.js | -| **Full (production)** | vue.min.js | - | - | -| **Runtime-only (production)** | vue.runtime.min.js | - | - | +| **Full** | vue.js | vue.common.js | vue.esm.js | vue.esm.browser.js | +| **Runtime-only** | vue.runtime.js | vue.runtime.common.js | vue.runtime.esm.js | - | +| **Full (production)** | vue.min.js | - | - | vue.esm.browser.min.js | +| **Runtime-only (production)** | vue.runtime.min.js | - | - | - | ### Terms @@ -87,7 +101,11 @@ In the [`dist/` directory of the NPM package](https://cdn.jsdelivr.net/npm/vue/d - **[CommonJS](http://wiki.commonjs.org/wiki/Modules/1.1)**: CommonJS builds are intended for use with older bundlers like [browserify](http://browserify.org/) or [webpack 1](https://webpack.github.io). The default file for these bundlers (`pkg.main`) is the Runtime only CommonJS build (`vue.runtime.common.js`). -- **[ES Module](http://exploringjs.com/es6/ch_modules.html)**: ES module builds are intended for use with modern bundlers like [webpack 2](https://webpack.js.org) or [rollup](https://rollupjs.org/). The default file for these bundlers (`pkg.module`) is the Runtime only ES Module build (`vue.runtime.esm.js`). +- **[ES Module](http://exploringjs.com/es6/ch_modules.html)**: starting in 2.6 Vue provides two ES Modules (ESM) builds: + + - ESM for bundlers: intended for use with modern bundlers like [webpack 2](https://webpack.js.org) or [rollup](https://rollupjs.org/). ESM format is designed to be statically analyzable so the bundlers can take advantage of that to perform "tree-shaking" and eliminate unused code from your final bundle. The default file for these bundlers (`pkg.module`) is the Runtime only ES Module build (`vue.runtime.esm.js`). + + - ESM for browsers (2.6+ only): intended for direct imports in modern browsers via ` ``` -If you are using ES Modules, there is also an ES Modules compatible build: +If you are using native ES Modules, there is also an ES Modules compatible build: ``` html @@ -130,37 +130,40 @@ Here the argument is the event name to listen to. We will talk about event handl ### Dynamic Arguments -> New in 2.6 +> New in 2.6.0+ -Starting in 2.6, it is also possible to use JavaScript expressions in an directive argument by wrapping it with square brackets: +Starting in version 2.6.0, it is also possible to use a JavaScript expression in a directive argument by wrapping it with square brackets: ``` html - ... + ... ``` -Here `key` will be dynamically evaluated as a JavaScript expression, and its evaluated value will be used as the final value for the argument. For example, if your Vue instance has a data property `key` whose value is `"href"`, then this binding will be equivalent to `v-bind:href`. +Here `attributeName` will be dynamically evaluated as a JavaScript expression, and its evaluated value will be used as the final value for the argument. For example, if your Vue instance has a data property, `attributeName`, whose value is `"href"`, then this binding will be equivalent to `v-bind:href`. -Similarly, you can use dynamic arguments to bind a handler to a dynamic event: +Similarly, you can use dynamic arguments to bind a handler to a dynamic event name: ``` html - ... + ... ``` +Similarly, when `eventName`'s value is `"focus"`, for example, `v-on:[eventName]` will be equivalent to `v-on:focus`. + #### Dynamic Argument Value Constraints -Dynamic argument values are expected to be strings, with the exception of `null`. The special value `null` can be used to explicitly remove the binding. Any other non-string value will trigger a warning. +Dynamic arguments are expected to evaluate to a string, with the exception of `null`. The special value `null` can be used to explicitly remove the binding. Any other non-string value will trigger a warning. #### Dynamic Argument Expression Constraints -

Dynamic argument expressions have some syntax constraints because certain characters are invalid inside HTML attribute names, in particular spaces and quotes.

+

Dynamic argument expressions have some syntax constraints because certain characters are invalid inside HTML attribute names, such as spaces and quotes.

For example, the following is invalid: ``` html + ... ``` -The Vue template compiler will warn against such usage. The workaround is to either use expressions without spaces or quotes, or use a computed property instead. +The workaround is to either use expressions without spaces or quotes, or replace the complex expression with a computed property. ### Modifiers @@ -174,7 +177,7 @@ You'll see other examples of modifiers later, [for `v-on`](events.html#Event-Mod ## Shorthands -The `v-` prefix serves as a visual cue for identifying Vue-specific attributes in your templates. This is useful when you are using Vue.js to apply dynamic behavior to some existing markup, but can feel verbose for some frequently used directives. At the same time, the need for the `v-` prefix becomes less important when you are building a [SPA](https://en.wikipedia.org/wiki/Single-page_application) where Vue.js manages every template. Therefore, Vue.js provides special shorthands for two of the most often used directives, `v-bind` and `v-on`: +The `v-` prefix serves as a visual cue for identifying Vue-specific attributes in your templates. This is useful when you are using Vue.js to apply dynamic behavior to some existing markup, but can feel verbose for some frequently used directives. At the same time, the need for the `v-` prefix becomes less important when you are building a [SPA](https://en.wikipedia.org/wiki/Single-page_application), where Vue manages every template. Therefore, Vue provides special shorthands for two of the most often used directives, `v-bind` and `v-on`: ### `v-bind` Shorthand @@ -189,9 +192,9 @@ The `v-` prefix serves as a visual cue for identifying Vue-specific attributes i ... ``` -> DOM Property Shorthand +#### DOM Property Shorthand -In 2.6 a separate shorthand for explicit DOM property bindings (with the `.prop` modifier) have been introduced: +In 2.6.0+, a separate shorthand for explicit DOM property bindings (with the `.prop` modifier) have been introduced: ``` html @@ -214,4 +217,4 @@ In 2.6 a separate shorthand for explicit DOM property bindings (with the `.prop` ... ``` -They may look a bit different from normal HTML, but `:` and `@` are valid chars for attribute names and all Vue.js supported browsers can parse it correctly. In addition, they do not appear in the final rendered markup. The shorthand syntax is totally optional, but you will likely appreciate it when you learn more about its usage later. +They may look a bit different from normal HTML, but `:` and `@` are valid characters for attribute names and all Vue-supported browsers can parse it correctly. In addition, they do not appear in the final rendered markup. The shorthand syntax is totally optional, but you will likely appreciate it when you learn more about its usage later. From 985c4b7d26c9b829143310a8c41863c5ebf25c53 Mon Sep 17 00:00:00 2001 From: Chris Fritz Date: Fri, 1 Feb 2019 16:48:22 -0500 Subject: [PATCH 22/25] tweaks to v-slot docs --- src/v2/api/index.md | 26 ++- src/v2/guide/components-slots.md | 304 ++++++++++++++++++++++--------- 2 files changed, 230 insertions(+), 100 deletions(-) diff --git a/src/v2/api/index.md b/src/v2/api/index.md index 637eb47344..5343413e01 100644 --- a/src/v2/api/index.md +++ b/src/v2/api/index.md @@ -2224,11 +2224,11 @@ type: api - **Expects:** JavaScript expression that is valid in a function argument position (supports destructuring in [supported environments](../guide/components-slots.html#Slot-Props-Destructuring)). Optional - only needed if expecting props to be passed to the slot. -- **Argument:** `slot name (optional)` +- **Argument:** slot name (optional, defaults to `default`) - **Limited to:** - `