React+Taro 微信小程序做一个页面,背景图需贴手机屏幕最上边覆盖展示

话不多说 直接上图

第一步

bash 复制代码
import { getSystemInfoSync } from '@tarojs/taro';

第二步

bash 复制代码
render() {
    const cardBanner = getImageUrlByGlobal('member-merge-bg.png');
    const { safeArea, statusBarHeight } = getSystemInfoSync();
    const NAV_BAR_HEIGHT = 44;
    const navBarHeight = NAV_BAR_HEIGHT + (statusBarHeight || safeArea.top);
    const containerStyle = {
      paddingTop: navBarHeight,
      backgroundImage: `url(${cardBanner})`
    };
    return <View className={prefix} style={containerStyle}></View>;
  }

第三步样式

bash 复制代码
.member-merge{
  display: flex;
  flex: 1;
  flex-direction: column;
  background-color: #f5f5f5;
  background-size: 100% auto;
  background-position: top left;
  background-repeat: no-repeat;
}
相关推荐
海岳云舟2 小时前
通过Spring Authorization Server对微信小程序应用进行授权防护
微信小程序
nunumaymax7 小时前
【第九章-React Router 6】
前端·react.js
Java陈序员20 小时前
轻量运维面板!一款现代化的服务器控制面板工具!
运维·服务器·python·react.js·github
阿祖zu1 天前
训练师 Agent 小程序产品上线啦
微信小程序·llm·agent
光影少年1 天前
RN首屏加载速度优化全方案
react native·react.js·掘金·金石计划
前端精髓1 天前
React 更新 state 中的对象
javascript·react.js·ecmascript
10share1 天前
我为什么用 React 重写了一个 VitePress
前端·react.js
天道kabuto1 天前
前端每日知识点:React 与 Vue Diff 算法对比 · 完整总结
vue.js·react.js·前端框架
moMo1 天前
React 全栈实战:从组件到鉴权的完整指南
react.js