API

全局配置

Vue.config 是一个对象,包含 Vue 的全局配置。可以在启动应用程序之前,预先修改下列属性:

silent

optionMergeStrategies

devtools

errorHandler

warnHandler

2.4.0+ 新增

ignoredElements

keyCodes

performance

2.2.0+ 新增

productionTip

2.2.0+ 新增

全局 API

Vue.extend( options )

Vue.nextTick( [callback, context] )

Vue.set( target, key, value )

Vue.delete( target, key )

Vue.directive( id, [definition] )

Vue.filter( id, [definition] )

Vue.component( id, [definition] )

Vue.use( plugin )

Vue.mixin( mixin )

Vue.compile( template )

Vue.version

选项 / 数据

data

props

propsData

computed

methods

watch

选项 / DOM

el

template

render

renderError

2.2.0+ 新增

选项 / 生命周期钩子

所有的生命周期钩子自动绑定 this 上下文到实例中,因此你可以访问数据,对属性和方法进行运算。这意味着 你不能使用箭头函数来定义一个生命周期方法 (例如 created: () => this.fetchTodos())。这是因为箭头函数绑定了父上下文,因此 this 与你期待的 Vue 实例不同, this.fetchTodos 的行为未定义。

beforeCreate

created

beforeMount

mounted

beforeUpdate

updated

activated

deactivated

beforeDestroy

destroyed

errorCaptured

2.5.0+ 新增

选项 / 资源

directives

包含 Vue 实例可用指令的哈希表。

filters

包含 Vue 实例可用过滤器的哈希表。

components

包含 Vue 实例可用组件的哈希表。

选项 / 杂项

parent

mixins

extends

provide / inject

2.2.0+ 新增

选项 / 其它

name

delimiters

functional

model

2.2.0 新增

inheritAttrs

2.4.0+ 新增

comments

2.4.0+ 新增

实例属性

vm.$data

vm.$props

2.2.0+ 新增

一个对象,代表当前组件收到的 props。Vue 实例代理访问到这个 props 对象的属性们。

vm.$el

vm.$options

vm.$parent

vm.$root

vm.$children

vm.$slots

vm.$scopedSlots

2.1.0+ 新增

vm.$refs

vm.$isServer

vm.$attrs

vm.$listeners

实例方法 / 数据

vm.$watch( expOrFn, callback, [options] )

注意:在变异(不是替换)对象或数组时,旧值将与新值相同,因为它们的引用指向同一个对象/数组。Vue 不会保留变异之前值的副本。

vm.$set( target, key, value )

vm.$delete( target, key )

实例方法/事件

vm.$on( event, callback )

vm.$once( event, callback )

vm.$off( [event, callback] )

vm.$emit( event, […args] )

实例方法 / 生命周期

vm.$mount( [elementOrSelector] )

vm.$forceUpdate()

vm.$nextTick( [callback] )

vm.$destroy()

指令

v-text

v-html

v-show

v-if

v-else

v-else-if

2.1.0+ 新增

v-for

v-on

v-bind

v-model

v-pre

v-cloak

v-once

特殊属性

key

ref

slot

slot-scope

2.5.0+ 新增

scope 替换

用于表示一个作为带作用域的插槽的 <template> 元素,它在 2.5.0+ 中被 slot-scope 替代。

is

内置组件

component

transition

transition-group

keep-alive

slot

VNode 接口

服务端渲染


原文:https://vuejs.org/v2/api/