HarmonyOS应用开发-放大与缩小效果展现

HarmonyOS应用开发-放大与缩小效果展现_第1张图片

Hml

 Css

.container {
    flex-direction: column;
    justify-content: center;
    align-items: center;
    width: 100%;
    height: 100%;
}
.box{
    flex-direction: column;
    justify-content: center;
    align-items: center;
    width: 400px;
    height: 400px;
}

Js

import prompt from '@system.prompt';
let width = 200;
let height = 200;
export default {
    data: {
        widthVal:width,
        heightVal:height,
    },
    enlarge(){
        if (width < 400) {
            width +=10;
            height +=10;
            this.widthVal = width
            this.heightVal = height
        }else {
            prompt.showToast({message:"已经达到最大"})
        }
    },
    decrease(){
        if (width > 180) {
            width -=10;
            height -=10;
            this.widthVal = width
            this.heightVal = height
        }else{
            prompt.showToast({message:"不能再缩小了"})

        }
    },
}

效果展示:

HarmonyOS应用开发-放大与缩小效果展现_第2张图片

 

你可能感兴趣的:(harmonyos)