为了实现设置vue移动端背景色填充满屏幕,并且滑动屏幕同样设有颜色
给body元素增加::before伪元素来实现这个效果,再给伪元素增加样式即可
例如:
<template>
<div class="confirm_order">
<Toolbar title="确认订单" @back="goback"></Toolbar>
<div class="confirm_content">
</div>
</div>
</template>
<style scoped lang="less" rel="stylesheet/less">
.confirm_order {
background-color: #F8F8F8;
// min-height: 100vh;
&::before {
content: ' ';
position: fixed;
z-index: -1;
top: 0;
right: 0;
bottom: 0;
left: 0;
background: #F8F8F8;
background-size: 100% auto;
}
}
</style>