跳到主要内容

Watch

API 文档

用于侦听属性,来响应数据的变化,也就是侦听属性。

有两个属性:immediate、deep

immediate:该回调将会在侦听开始之后被立即调用

deep:该回调会在任何被侦听的对象的 property 改变时被调用,不论其被嵌套多深

Mixins 混入

文档

Extends 继承

更多的是 Vue 的扩展

const MyVue = Vue.extend({
data() {
return {
name: '',
time: undefined
}
},
created() {
if (!this.name) {
console.error('no name!')
}
this.time = new Date()
},
beforeDestroy() {
const duration = new Date() - this.time
console.log(`${this.name} ${duration}`)
}
})

Provide 与 inject

提供/注入

父级提供数据与方法,组件通过 inject 接收数据与方法