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
// `type` is a Vue-specific error type, e.g. which lifecycle hook
76
+
// the error was found in. Only available in 2.2.0+
75
77
}
76
78
```
77
79
78
-
Assign a handler for uncaught errors during component render and watchers. The handler gets called with the error and the Vue instance.
80
+
Assign a handler for uncaught errors during component render function and watchers. The handler gets called with the error and the Vue instance.
81
+
82
+
> In 2.2.0, this hook also captures errors in component lifecycle hooks. Also, when this hook is `undefined`, captured errors will be logged with `console.error` instead of crashing the app.
79
83
80
84
> [Sentry](https://sentry.io), an error tracking service, provides [official integration](https://sentry.io/for/vue/) using this option.
81
85
@@ -114,6 +118,30 @@ type: api
114
118
115
119
Define custom key alias(es) for v-on.
116
120
121
+
### performance
122
+
123
+
> New in 2.2.0
124
+
125
+
-**Type:**`boolean`
126
+
127
+
-**Default:**`false`
128
+
129
+
-**Usage**:
130
+
131
+
Set this to `true` to enable component init, compile, render and patch performance tracing in the browser devtool timeline. Only works in development mode and in browsers that support the [performance.mark](https://developer.mozilla.org/en-US/docs/Web/API/Performance/mark) API.
132
+
133
+
### productionTip
134
+
135
+
> New in 2.2.0
136
+
137
+
-**Type:**`boolean`
138
+
139
+
-**Default:**`true`
140
+
141
+
-**Usage**:
142
+
143
+
Set this to `false` to prevent the production tip on Vue startup.
144
+
117
145
## Global API
118
146
119
147
<h3id="Vue-extend">Vue.extend( options )</h3>
@@ -195,17 +223,19 @@ type: api
195
223
196
224
-**See also:**[Reactivity in Depth](../guide/reactivity.html)
197
225
198
-
<h3id="Vue-delete">Vue.delete( object, key )</h3>
226
+
<h3id="Vue-delete">Vue.delete( target, key )</h3>
199
227
200
228
-**Arguments:**
201
-
-`{Object} object`
202
-
-`{string} key`
229
+
-`{Object | Array} target`
230
+
-`{string | number} key`
203
231
204
232
-**Usage:**
205
233
206
234
Delete a property on an object. If the object is reactive, ensure the deletion triggers view updates. This is primarily used to get around the limitation that Vue cannot detect property deletions, but you should rarely need to use it.
207
235
208
-
**Note the object cannot be a Vue instance, or the root data object of a Vue instance.**
236
+
> Also works with on Array + index in 2.2.0+.
237
+
238
+
<pclass="tip">The target object cannot be a Vue instance, or the root data object of a Vue instance.</p>
209
239
210
240
-**See also:**[Reactivity in Depth](../guide/reactivity.html)
-**Details**: Provides the installed version of Vue as a string. This is especially useful for community plugins and components, where you might use different strategies for different versions.
Provide an alternative render output when the default `render` function encounters an error. The error will be passed to `renderError` as the second argument. This is particularly useful when used together with hot-reload.
All lifecycle hooks automatically have their `this` context bound to the instance, so that you can access data, computed properties, and methods. This means __you should not use an arrow function to define a lifecycle method__ (e.g. `created: () => this.fetchTodos()`). The reason is arrow functions bind the parent context, so `this` will not be the Vue instance as you expect and `this.fetchTodos` will be undefined.
@@ -774,7 +832,7 @@ All lifecycle hooks automatically have their `this` context bound to the instanc
774
832
- **See also:**
775
833
- [Components](../guide/components.html)
776
834
777
-
## Options / Misc
835
+
## Options / Composition
778
836
779
837
### parent
780
838
@@ -812,18 +870,6 @@ All lifecycle hooks automatically have their `this` context bound to the instanc
812
870
813
871
- **See also:** [Mixins](../guide/mixins.html)
814
872
815
-
### name
816
-
817
-
-**Type:**`string`
818
-
819
-
-**Restriction:** only respected when used as a component option.
820
-
821
-
-**Details:**
822
-
823
-
Allow the component to recursively invoke itself in its template. Note that when a component is registered globally with `Vue.component()`, the global ID is automatically set as its name.
824
-
825
-
Another benefit of specifying a `name` option is debugging. Named components result in more helpful warning messages. Also, when inspecting an app in the [vue-devtools](https://github.com/vuejs/vue-devtools), unnamed components will show up as `<AnonymousComponent>`, which isn't very informative. By providing the `name` option, you will get a much more informative component tree.
826
-
827
873
### extends
828
874
829
875
- **Type:** `Object|Function`
@@ -846,6 +892,77 @@ All lifecycle hooks automatically have their `this` context bound to the instanc
<p class="tip">`provide` and `inject` are primarily provided for advanced plugin / component library use cases. It is NOT recommended to use them in generic application code.</p>
906
+
907
+
This pair of options are used together to allow an ancestor component to serve as a dependency injector for its all descendants, regardless of how deep the component hierarchy is. If you are familiar with React, this is very similar to React's context feature.
908
+
909
+
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.
910
+
911
+
The `inject` options should be either an Array of strings or an object where the keys stand for the local binding name, and the value being the key (string or Symbol) to search for in available injections.
912
+
913
+
The provider component must be in the parent chain of the component that wishes to inject the provided properties.
914
+
915
+
- **Example:**
916
+
917
+
``` js
918
+
var Provider = {
919
+
provide: {
920
+
foo:'bar'
921
+
},
922
+
// ...
923
+
}
924
+
925
+
var Child = {
926
+
inject: ['foo'],
927
+
created () {
928
+
console.log(this.foo) // -> "bar"
929
+
}
930
+
// ...
931
+
}
932
+
```
933
+
934
+
With ES2015 Symbols, function `provide` and object `inject`:
935
+
``` js
936
+
consts=Symbol()
937
+
938
+
constProvider= {
939
+
provide () {
940
+
return {
941
+
[s]:'foo'
942
+
}
943
+
}
944
+
}
945
+
946
+
constChild= {
947
+
inject: { s },
948
+
// ...
949
+
}
950
+
```
951
+
952
+
## Options / Misc
953
+
954
+
### name
955
+
956
+
- **Type:** `string`
957
+
958
+
- **Restriction:** only respected when used as a component option.
959
+
960
+
- **Details:**
961
+
962
+
Allow the component to recursively invoke itself in its template. Note that when a component is registered globally with `Vue.component()`, the global ID is automatically set as its name.
963
+
964
+
Another benefit of specifying a `name` option is debugging. Named components result in more helpful warning messages. Also, when inspecting an app in the [vue-devtools](https://github.com/vuejs/vue-devtools), unnamed components will show up as `<AnonymousComponent>`, which isn't very informative. By providing the `name` option, you will get a much more informative component tree.
965
+
849
966
### delimiters
850
967
851
968
- **Type:** `Array<string>`
@@ -876,6 +993,46 @@ All lifecycle hooks automatically have their `this` context bound to the instanc
Allows a custom component to customize the prop and event used when it's used with `v-model`. By default, `v-model` on a component uses `value` as the prop and `input` as the event, but some input types such as checkboxes and radio buttons may want to use the `value` prop for a different purpose. Using the `model` option can avoid the conflict in such cases.
1005
+
1006
+
- **Example:**
1007
+
1008
+
``` js
1009
+
Vue.component('my-checkbox', {
1010
+
model: {
1011
+
prop:'checked',
1012
+
event:'change'
1013
+
},
1014
+
props: {
1015
+
// this allows using the `value` prop for a different purpose
0 commit comments