Fork me on GitHub

Vue【二】

定义一个Vue实例常用的4个选项

filter过滤器

1
2
3
4
5
filters:{
toInt(value){
return parseInt(value);
}
}

computed计算属性

1
2
3
4
5
computed:{
sum(){
return this.num1+this.num2+this.num3
}
}

methods方法

1
2
3
4
5
methods:{
plus(){
return this.a++;
}
}

watch 观察

1
2
3
4
5
6
watch:{
a(){
console.log(`有变化了,最新值:`);
console.log(this.a);
}
}

生命周期

生命周期

据说帅的人都赏给博主几块钱零花钱。