解决思路:
使用flex布局来实现button的水平垂直居中,并使用绝对定位来实现button的水平垂直居中
示例代码如下:
<template>
<view class="container">
<button type="default" class="center">我是按钮</button>
</view>
</template>
<style>
.container {
position: relative;
height: 100%;
}
.center {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
}
</style>
网友评论