uni-app 背景图片绑定问题

uni-app由于的图片处理为了兼容小程序,禁止了使用本地图片(相对或者绝对路径) ,可以使用网络图片和base64格式的图片

如果非常想用本地图片,这图片大小不能超过40kb,否则需要转换成base64

在引用图片的时候我发现我一开始我把图片放在再index文件夹(首页文件夹)下面,

然后编译到小程序我发现小程序里面index文件夹(首页文件夹)里面并没有图片

也就是图片放在了首页等等html文件的文件夹中的图片不能编译到其他环境

图片需要另创建一个文件夹来存放,此时就可以编译到其他平台都有这张图片了

<template>
	<view class="app">
		<view class="profile-head" :style="{backgroundImage:'url('+imgUrl+')'}">
			<view class="profile-img">
				<image src="../../static/image/my/aaas.jpg" mode="widthFix" ></image>
			</view>
		</view>
	</view>
</template>

<script>
	let app  = ''
	export default {
		data() {
			return {
				imgUrl:"../../static/image/my/aaas.jpg"
			}
		},
		onLoad() {
			app = getApp()
			// console.log(app.globalData.systemInfo)
			console.log(this)
		
		},
		methods: {
			
		}
	}
</script>
<template>
	<view class="app">
		<view class="profile-head" style="background-image:url(../../static/image/my/aaas.jpg)">
			<view class="profile-img">
				<image src="../../static/image/my/aaas.jpg" mode="widthFix" ></image>
			</view>
		</view>
	</view>
</template>

页面效果

在这里插入图片描述
在这里插入图片描述

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值