vue computed计算属性demo,
<template>
<view>
<view class="font">
{{ ZHweight }} //直接调用计算函数中定义的函数名。
</view>
</view>
</template>
<script>
export default {
data() {
return {
//体重
weight:1500
}
},
computed:{
ZHweight:function(){
return this.weight>1000 ? (this.weight/1000)+'kg':this.weight+'g';
}
},
methods:{
}
}
</script>
<style>
.font{
font-size: 50upx;
}
</style>
浙公网安备 33010602011771号
