脚本宝典收集整理的这篇文章主要介绍了[译] Vue 2.0 的变化(一)之基本 API 变化,脚本宝典觉得挺不错的,现在分享给大家,也给大家做个参考。
模板解析器不再依赖于DOM(除非你使用真正的DOM作为模板),因此只要你使用字符串模板,你将不再受到任何1.0版本中的解析限制。但是,如果你依赖在存在的内容中挂载一个元素作为模板(使用el
元素),你将依然受到这些限制。
编译器(将字符串模板转换为渲染方法的部分)和运行时间现在能够被分开。这里有两种不同的构建:
Vue.config.optionMergeStrategies
Vue.config.devtools
Vue.config.errorHandler
(新API,全局的挂钩用于在组件渲染和监控的时候处理未捕获的错误)
Vue.config.keyCodes
(新API,为v-on
配置自定义的key
的别名)
(已丢弃)Vue.config.debug
(已丢弃)Vue.config.async
(已丢弃)Vue.config.delimITers
(已丢弃,使用Vue.config.unsafeDelimiters
v-htML
)
Vue.extend
Vue.nextTick
Vue.delete
Vue.component
Vue.mixin
Vue.COMpile
(新API,只能用于独立版本构建)
Vue.transition
(已丢弃,在stagger
el
上设置
Vue.filter
(已丢弃,使用组件)Vue.elementDirective
(已丢弃,使用功能组件)Vue.partial
data
PRops
prop
default
(已丢弃,如果你需要转换coerce
prop
,请使用compute
属性)
(已丢弃,prop binding modes
v-model
在组件上可以工作
propsdata
(新API)只能用于实例
computed
methods
watch
el
template
render
(新API)
(已丢弃,组件现在必须有一个根元素)replace
(已丢弃,请使用init
beforeCreate
)
created
beforedestroy
destroyed
beforemount
(新API)
mounted
(新API)
beforeUpdate
(新API)
updated
(新API)
activated
(新API,用于keep-alive
)
deactivated
(新API用于keep-alive
)
(已丢弃,使用ready
mounted
)
(已丢弃,迁移到activate
vue-router
)
(已丢弃,使用beforeCompile
created
)
(已丢弃,使用compiled
mounted
)
(已丢弃)attached
(已丢弃,同上)detached
directives
components
transitions
(已丢弃)partials
(已丢弃)elementDirectives
parent
mixins
name
extends
delimiters
(新API,替代原版的全局配置选项,只在独立构建中可用)
functional
(新API)
(已丢弃)events
vm.$watch
(已丢弃,直接检索值)vm.$get
(已丢弃,使用vm.$set
Vue.set
)
(已丢弃,使用vm.$delete
vue.delete
)
(已丢弃,没有真正的使用)vm.$eval
(已丢弃,同上)vm.$interpolate
(已丢弃,使用vm.$LOG
devtools
)
vm.$on
vm.$once
vm.$off
vm.$emit
(已丢弃,使用全局的事件或使用vm.$dispatch
vuex
,见下面)
(已丢弃,同上)vm.$broadcast
vm.$nextTick
(已丢弃,在vm.$apPEndTo
vm.$el
上使用本地API)
(已丢弃)vm.$before
(已丢弃)vm.$after
(已丢弃)vm.$remove
vm.$mount
vm.$destroy
v-text
v-html
(注意{{{ }}}
被丢弃)
v-else
v-for
key
(替代 track-by
)
object v-for
range v-for
参数顺序更新:数组中使用(value, index) in arr
,对象中使用(value, key, index) in obj
和$index
被丢弃$key
v-on
modifiers
on child component
自定义键码,目前版本Vue.config.keyCodes
代替原来的Vue.directive('on').keyCodes
v-bind
作为prop
xlink
绑定对象
v-bind:style
prefix sniffing
v-bind:class
v-model
lazy
(as modifier)
number
(as modifier)
ignoring composition events
(已丢弃,使用debounce
v-on:input
)
v-cloak
v-pre
v-once
(新API)
(已丢弃,现在只是一个特殊的属性v-ref
ref
)
(和v-el
ref
合并)
<component>
:is
async组件
inline-template
<transition>
<transition-group>
<keep-alive>
<slot>
(已丢弃)partial
key
ref
slot
renderToString
renderToStream
client-side hydration
以上是脚本宝典为你收集整理的[译] Vue 2.0 的变化(一)之基本 API 变化全部内容,希望文章能够帮你解决[译] Vue 2.0 的变化(一)之基本 API 变化所遇到的问题。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。