diff --git a/src/api/application-api.md b/src/api/application-api.md index 6acc202be3..3aa702ede4 100644 --- a/src/api/application-api.md +++ b/src/api/application-api.md @@ -158,7 +158,7 @@ Apart from `el`, you should treat these arguments as read-only and never modify - **Usage:** - Apply a mixin in the whole application scope, which will affect **every** Vue instance created afterwards in the given app (for example, child components). This can be used by plugin authors to inject custom behavior into components. **Not recommended in application code**. + Apply a mixin in the whole application scope. Once registered they can be used in the template of any component within the current application. This can be used by plugin authors to inject custom behavior into components. **Not recommended in application code**. - **See also:** [Global Mixin](../guide/mixins.html#global-mixin) @@ -192,44 +192,6 @@ app.mount('#my-app') - **See also:** - [Lifecycle Diagram](../guide/instance.html#lifecycle-diagram) -## provide - -- **Type:** - - - `Object | () => Object` - -- **Details:** - - This option is [used together with `inject`](../api/options-composition.html#provide-inject) to allow an ancestor component to serve as a dependency injector for all its descendants, regardless of how deep the component hierarchy is, as long as they are in the same parent chain. - - The `provide` option should be an object or a function that returns an object. This object contains the properties that are available for injection into its descendants. You can use ES2015 Symbols as keys in this object, but only in environments that natively support `Symbol` and `Reflect.ownKeys`. - - > Note: the `provide` and `inject` bindings are NOT reactive. This is intentional. However, if you pass down an observed object, properties on that object do remain reactive. - -- **Example:** - -```js -import { createApp } from 'vue' - -const app = createApp({ - provide: { - user: 'John Doe' - } -}) - -app.component('user-card', { - inject: ['user'], - template: ` -
@@ -95,11 +95,11 @@ Vue.createApp(AttributeBindingApp).mount('#bind-attribute')
-Here we're encountering something new. The `v-bind` attribute you're seeing is called a **directive**. Directives are prefixed with `v-` to indicate that they are special attributes provided by Vue, and as you may have guessed, they apply special reactive behavior to the rendered DOM. Here we are basically saying "_keep this element's `title` attribute up-to-date with the `message` property on the Vue instance._" +Here we're encountering something new. The `v-bind` attribute you're seeing is called a **directive**. Directives are prefixed with `v-` to indicate that they are special attributes provided by Vue, and as you may have guessed, they apply special reactive behavior to the rendered DOM. Here we are basically saying "_keep this element's `title` attribute up-to-date with the `message` property on the current active instance._" ## Handling User Input -To let users interact with your app, we can use the `v-on` directive to attach event listeners that invoke methods on our Vue instances: +To let users interact with your app, we can use the `v-on` directive to attach event listeners that invoke methods on our instances: ```html@@ -147,7 +147,7 @@ Vue also provides the `v-model` directive that makes two-way binding between for ``` ```js -const TwoWayBindingApp = { +const TwoWayBinding = { data() { return { message: 'Hello Vue!' @@ -155,7 +155,7 @@ const TwoWayBindingApp = { } } -Vue.createApp(TwoWayBindingApp).mount('#two-way-binding') +Vue.createApp(TwoWayBinding).mount('#two-way-binding') ```
@@ -176,7 +176,7 @@ It's easy to toggle the presence of an element, too: ``` ```js -const ConditionalRenderingApp = { +const ConditionalRendering = { data() { return { seen: true @@ -184,7 +184,7 @@ const ConditionalRenderingApp = { } } -Vue.createApp(ConditionalRenderingApp).mount('#conditional-rendering') +Vue.createApp(ConditionalRendering).mount('#conditional-rendering') ``` This example demonstrates that we can bind data to not only text and attributes, but also the **structure** of the DOM. Moreover, Vue also provides a powerful transition effect system that can automatically apply [transition effects](TODO) when elements are inserted/updated/removed by Vue. @@ -211,7 +211,7 @@ There are quite a few other directives, each with its own special functionality. ``` ```js -const ListRenderingApp = { +const ListRendering = { data() { return { todos: [ @@ -223,7 +223,7 @@ const ListRenderingApp = { } } -Vue.createApp(ListRenderingApp).mount('#list-rendering') +Vue.createApp(ListRendering).mount('#list-rendering') ```
@@ -239,7 +239,7 @@ The component system is another important concept in Vue, because it's an abstra  -In Vue, a component is essentially a Vue instance with pre-defined options. Registering a component in Vue is straightforward: we create a component object as we did with `App` objects and we define it in parent's `components` option: +In Vue, a component is essentially an instance with pre-defined options. Registering a component in Vue is straightforward: we create a component object as we did with `App` objects and we define it in parent's `components` option: ```js // Create Vue application @@ -275,7 +275,7 @@ app.component('todo-item', { Now we can pass the todo into each repeated component using `v-bind`: ```html -