Set to true to enable performance tracking of component initialization, compilation, rendering, and patching in the browser dev tools' performance/timeline panel [details](https://v2.cn.vuejs .org/v2/api/#performance)
√
x
x
Only supported in web environment
Vue.config.productionTip
Set to false to prevent vue from generating production tips on startup details
Use the base Vue constructor to create a "subclass" Details
√
√
x
No Use as a component
Vue.nextTick
Execute delayed callback after the end of the next DOM update loop details
√
x
x
Vue.set
Add a property to the responsive object, and make sure this new property is also responsive and triggers view updates [details](https://v2.cn.vuejs.org/v2/api/# Vue-set)
√
√
√
Vue.delete
Delete a property of an object. If the object is reactive, make sure the delete triggers an update view Details
props can be an array or an object to receive data from the parent component Details
√
√
√
propsData
Pass props when creating an instance. The main function is to facilitate testing Details
√
√
√
computed
Computed properties will be mixed into the Vue instance Details
√
√
√
methods
methods will be mixed into the Vue instance Details
√
√
√
watch
An object, the key is the expression to be observed, and the value is the corresponding callback function Details
√
√
√
el
Provide an existing DOM element on the page as the mount target of the Vue instance Details
√
x
x
template
A string template is used as the identifier of a Vue instance details
√
x
x
The vue used by uni-app is Include runtime version only
render
An alternative to string templates, the render function accepts a createElement method as the first argument to create the VNode. Details
√
x
x
renderError
When the render function encounters an error, another rendering output is provided, which only works in the developer environment Details
√
x
x
directives
Hash table containing directives available to Vue instance details
√
√
x
filters
Hash table containing available filters for Vue instances details
√
√
√
components
A hash table containing the components available for a Vue instance details
√
√
√
parent
Specifies the parent instance of the created instance and establishes a parent-child relationship between the two Details
√
√
√
Not recommended
mixins
option to receive an array of mixin objects details
√
√
√
extends
Allows declarations to extend another component Details
√
√
√
provide/inject
Allows an ancestor component to inject a dependency into all its descendants, no matter how deep the component level is, and it will always take effect when its upstream and downstream relationships are established [details](https://v2.cn.vuejs .org/v2/api/#provide-inject)
√
√
√
name
Allow component template to call itself recursively Details
√
√
√
delimiters
Change the delimiter for plain text insertion details
√
x
x
functional
Make a component stateless (no data) and instanceless (no this context) Details
√
x
x
model
Allows a custom component to customize props and events when using v-model Details
√
√
x
inheritAttrs
The default value of the inheritAttrs attribute is true, which means that the root node of the component is allowed to inherit the attributes contained in $attrs Details
√
√
x
comments
When set to true, HTML comments in the template will be preserved and rendered details
Call Details after it is mounted on the instance After the component is fully mounted, you can use $nextTick Details
√
√
√
beforeUpdate
Called when data is updated, before the virtual DOM is patched Details
√
√
√
updated
This hook will be called after the virtual DOM is re-rendered and patched due to data changes Details
√
√
√
activated
Called when a component cached by keep-alive is activated Details
√
√
x
deactivated
Called when a component cached by keep-alive is deactivated Details
√
√
x
beforeDestroy
Called before the instance is destroyed. At this step, the instance is still fully available Details
√
√
√
destroyed
Called after the Vue instance is destroyed. After the call, everything indicated by the Vue instance will be unbound, all event listeners will be removed, and all child instances will be destroyed [details](https://v2.cn.vuejs.org/v2/ api/#destroyed)
√
√
√
errorCaptured
Called when an error from a descendant component is captured Details
The props object received by the current component Details
√
√
√
vm.$el
The root DOM element used by the Vue instance details
√
x
x
vm.$options
Initialization options for the current Vue instance Details
√
√
√
vm.$parent
Parent instance, if the current instance exists details
√
√
√
H5 endView, text and other built-in tags are implemented in Vue components, $parent will get these to the built-in components, the problem is that this.$parent is inconsistent with other platforms, the solution is to use this.$ parent.$parent Get or customize the root node of the component from view to div
vm.$root
The root Vue instance of the current component tree Details
Renders a "meta-component" as a dynamic component. Determine which component is rendered according to the value of is Details
√
√
x
transition
Transition effect as a single element/component Details
√
x
x
transition-group
Transition effects as multiple elements/components Details
√
x
x
keep-alive
When wrapping dynamic components, inactive component instances are cached instead of destroying them Details
√
x
x
slot
As a content distribution slot in a component template Details
√
√
√
-
template
is not a component, it is just a wrapper element, it will not do any rendering in the page, it only accepts control properties [details](https://uniapp.dcloud.io/component/vue-component?id= template)
When Vue components are compiled to the applet platform, they will be compiled into components of the corresponding platform. Some applet platforms support the options option (for specific options, please refer to the custom components section of the corresponding applet platform documentation). Generally, the default can be used, if there are special requirements The options property can be added to the Vue component.
uni-app has built-in Vuex. For use in the app, please refer to hello-uniappstore/index.js.
//store.jsimport Vue from'vue'import Vuex from'vuex'
Vue.use(Vuex)const store =newVuex.Store({state:{...},mutations:{...},actions:{...}})exportdefault store
//main.js...import store from'./store'Vue.prototype.$store = store
const app =newVue({
store,...})...//test.vue When using:import{mapState,mapMutations}from'vuex'
Since onError is not a complete life cycle, only a method of catching errors is provided, and a callback function named onError can be added to the root component of the app. as follows:
exportdefault{// Only apps have an onLaunch lifecycleonLaunch(){// ...},// capture app erroronError(err){
console.log(err)}}
# 4. Component property settings do not take effect
When some properties are repeatedly set to the same value, they are not synchronized to the View layer. For example, every time you set the scroll-top property of a scroll-view component to 0, it only gets back to the top the first time. This is due to the props unidirectional data flow feature. When the actual value of scroll top inside the component changes, the binding properties do not change with it.
There are two solutions (take the scroll-view component as an example):
Monitor the scroll event, record the value of the internal change of the component, and set the current value of the record before setting the new value
exportdefault{data(){return{scrollTop:0,}},methods:{scroll:function(e){// If you use this method, please add debounce by yourselfthis.scrollTop = e.detail.scrollTop
},goTop:function(e){this.scrollTop =0}}}
The second solution may cause jitter in some components, and the first solution is recommended .