problem
微信小程序background-image不能加载本地图片
reason
微信小程序的限制
solution
将本地图片转成base64
工具: https://tool.chinaz.com/tools/imgtobase
/* before */
.card .content .title-bg {
background-image: url(../../image/[email protected]);
}
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 2dppx) {
.card .content .title-bg {
background-image: url(../../image/[email protected]);
}
}
/* after */
.card .content .title-bg {
background-image: url('data:image/png;base64,xxx');
}
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 2dppx) {
.card .content .title-bg {
background-image: url('data:image/png;base64,yyy');
}
}