uni-app 计算属性 computed

功能:=》大于1000用kg表示 小于1000,用g表示

    计算属性  计算属性必须是有一个返回值的哦  
    在html写被计算的值
    在computed中去直接调用哈

        <view>
            <text>{{jisuweight}}</text>
        </view>
        
        data() {
            return {
                weight:1110,
            }
        },
        computed:{
            jisuweight(){
                return this.weight>1000 ? (this.weight/1000)+"kg" : this.weight;
            }
        },
文章来自:https://www.cnblogs.com/IwishIcould/p/12184430.html
© 2021 jiaocheng.bubufx.com  联系我们
ICP备案:鲁ICP备09046678号-3