<template>
<p>{{ name.length>0 ? true : false }}</p>
<p>{{ commputedValue }}</p>
</template>
<script>
export default{
data(){
return{
name:"vue"
}
},
methods: {
},
computed:{
commputedValue(){
return this.name.length>0 ? true : false;
}
}
}
</script>
使用computed
对象。
在methods
可实现相同的结果。