<script>
export default {
data() {
return {
boxStyle: '', // 盒子样式
};
},
onLoad() {
// 获取胶囊按钮的位置信息
const rect = uni.getMenuButtonBoundingClientRect();
const statusBarHeight = uni.getSystemInfoSync().statusBarHeight; // 获取状态栏高度
// 计算盒子样式
this.boxStyle = `top: ${rect.bottom + statusBarHeight}px; right: ${rect.right}px;`;
},
};
</script>
<style>
.box {
position: fixed;
background-color: #ccc;
width: 200rpx;
height: 100rpx;
}
</style>