帮助了 AmazingCounters.com 位小伙伴

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>

 

posted on 2020-10-12 15:07  云的旋律  阅读(152)  评论(0)    收藏  举报

导航

前端攻城狮分享群