我是靠谱客的博主 俊秀大白,这篇文章主要介绍uni-app background 使用本地图片,现在分享给大家,希望可以做个参考。

  • 解释:css背景图片不能使用本地图片,官方给的理由是小程序不支持本地图片,只支持网络访问或者base64。
  • 所以uniapp也不支持,但是只要不超过40kb即可。 注意:把下面导入的图片路径改成你自己的。
  • 还有:如果图片大小超过40kb是不会自动转换的,需要程序员自己吧图片转换成base64格式
复制代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
<template> <view :style="{backgroundImage:`url(${indexBackgroundImage})`,backgroundSize: 'cover'}" > </view> </template> <script> import indexBackgroundImage from "@/static/images/myInfo/di.png" export default { data() { return { indexBackgroundImage:indexBackgroundImage }; }, } </script>

最后

以上就是俊秀大白最近收集整理的关于uni-app background 使用本地图片的全部内容,更多相关uni-app内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(69)

评论列表共有 0 条评论

立即
投稿
返回
顶部