计算属性(computed): 如果某个值需要计算之后渲染在页面中,那么不推荐直接把逻辑写在页面中,要写在computed
computed:{
status(){
}
}
computed:{
status:{
//getter
get:function(){
return this.message+this.info
},
/setter
set:function(){
this.fontObj.fontSize="100px"
}
}
一定要return一个值
计算属性:当所依赖的值发生变化,会自动计算
动态绑定属性
v-bind:属性名="变量"
关于class的动态绑定
v-bind:class="变量" 变量名代表class名
v-bind:class="对象" {class名:布尔值} 代表这个class有没有、
v-bind:class="[]" [class名,class名]
关于style的绑定
v-bind:style="对象" {样式名:样式值(变量),}
v-bind:style="数组" [样式对象1,样式对象2]
侦听器 watch 监测一个值,当值发生变化的时候主动触发一件事
列表渲染
v-for="每一项 in 要遍历的数据"
v-for="item in array"遍历一个数组 item代表数组的每一项 v-for="(value,key) in arr"
v-for="item in object"遍历一个对象 item代表对象的值 v-for="(value,key,index) in person"
v-for="item in 整数"