image替换背景图片,定位实现背景图片效果
<view class="test">
<image src="../../img/"></image>
<text>文字内容</text>
</view>
.test{
width:100rpx;
height:30rpx;
position:relative;
}
.test image{
width:100%;
height:100%;
}
.test text{
width:100%;
height:100%;
line-height:100%;
text-align:center;
position: absolute;
top:0;
left:0;
font-family:"PingFangSC-Semibold";
color:#fff;
font-size:18rpx;
}
最终图片放在另外一个H5项目中,可通过网络地址访问,以网络图片的形式访问,解决了背景图片显示的问题。