计算属性
<div id
="app">
<h1
>{{num1
+num2
}}</h1
>
<h1
>{{sum
}} </h1
>
<p
>{{msg2
}}</p
>
<p
>{{getMsg
}}</p
>
</div
>
<script
>
var app
=new Vue({
el
:'#app',
data
:(){
return{
msg2
:"ABCD",
suts
:[{
Name
:"001",
age
:18,
sex
:男
},
{
Name
:"002",
age
:19,
sex
:女
},
{
Name
:"003",
age
:20,
sex
:女
},
{
Name
:"004",
age
:21,
sex
:女
},]
}
},
watch:
{
msg2
:function(val
){
console
.log("我msg2改变成"+val
)
}
}
computed
:{
getStu
:function(){
var res
=this.stus
.filter((item
,i
)=>{
return item
.age
%2==0;
})
return res
}
getMsg
:{
get:function(){
return this.msg2
.split('').resvers('').jion('')
set:function(val
){
return this.msg2
=val
.split('').resvers().jion('')
}
}
}
}
})
</script
>
转载请注明原文地址:https://tech.qufami.com/read-17917.html