uniapp img 动态渲染 的几种用法

img => src 的动态变化

复制代码
	<img src="https://yjtravelphotography.oss-cn-hangzhou.aliyuncs.com/shop/login_bg.png"
			class="page_background"></img>

<img style="width: 160rpx; height: 160rpx; border-radius: 10rpx;"
											:src="item.picImage"></img>



<template>
  <scroll-view scroll-y="true" @scrolltolower="scrollToLower"
					style="height:calc(100% - 56px - 90rpx);padding: 0 20rpx;">
					<u-radio-group @change="groupChange">
						<u-radio v-for="(item, index) in radiolist" :key="index" :name="item.name">
							<view class="menu_item">
								<view class="u-flex">
									<view>
										<img style="width: 160rpx; height: 160rpx; border-radius: 10rpx;"
											:src="item.picImage"></img>
									</view>
									<view class="u-flex-col u-row-around u-margin-left-20" style="height: 160rpx;">
										<!-- <view class="goods_title">{{item.name}}</view> -->
										<view class="goods_title">299 元畅享延吉公主体验:服装 + 妆造 + 拍摄一站式旅拍套餐</view>
										<view class="goods_price">
											分类:单人照
										</view>
										<view class="u-flex u-row-between u-col-center">
											<view class="goods_price">
												¥ <label style="font-size: 40rpx;font-weight: 540;"> 299.00 </label>
											</view>
											<view class="u-font-26">年售 28</view>
										</view>
									</view>
								</view>
							</view>
						</u-radio>
					</u-radio-group>
				</scroll-view>
</template>

<script>
export default {
        data(){
            return{
                radiolist: [{
						name: '苹果',
						disabled: false,
						picImage: "https://yjtravelphotography.oss-cn-hangzhou.aliyuncs.com/shop/logo.png"

					},
					{
						name: '香蕉',
						disabled: false,
						picImage: "https://yjtravelphotography.oss-cn-hangzhou.aliyuncs.com/resources/20250919/1758272222955.jpg"
					},
					{
						name: '橙子',
						disabled: false,
						picImage: "https://yjtravelphotography.oss-cn-hangzhou.aliyuncs.com/shop/logo.png"
					}, {
						name: '榴莲',
						disabled: false,
						picImage: "https://yjtravelphotography.oss-cn-hangzhou.aliyuncs.com/resources/20250919/1758272222955.jpg"
					}
				],
            }
        }
}
</script>

<style>

</style>


backgroundImage 动态背景图片 以及 标签传值

1. 背景图片
复制代码
   <view 
				      class="image"
				      :style="{ backgroundImage: `url(${item.iamge})` }"
				    ></view>
2. 标签传值
复制代码
<template>

				<view 
				  class="item" 
				  v-for="(item, index) in sampleList" 
				  :key="index"
				@click="toPage('/subPackages/association/pages/association/followshotadd?image='+item.sampleImage+'&id='+item.id)"
				>
				
				</view>
			
</template>

<script>
export default {
        data(){
            return{
              
            }
        }
        methods(){
            toPage(item) { 
		  uni.navigateTo({ url: item });  
		}
        }
}
</script>

<style>
3. 动态背景图片 以及 标签传值 完整代码
复制代码
<template>
	<scroll-view scroll-y="true" @scrolltolower="scrollToLower"
				:style="'height:calc(100vh - '+(fixedHeigth+navBarHeight+20)+'px);'">
			
				<view class="menu">
				<view 
				  class="item" 
				  v-for="(item, index) in sampleList" 
				  :key="index"
				@click="toPage('/subPackages/association/pages/association/followshotadd?image='+item.sampleImage+'&id='+item.id)"
				>
				    <view 
				      class="image"
				      :style="{ backgroundImage: `url(${item.iamge})` }"
				    ></view>
				    
				    <view class="u-padding-18 u-font-26">
				      <view>{{ item.name || '民俗园打卡 ▪ 传统服饰' }}</view>
				      <view class="u-margin-top-20" style="color: gray;">
				        {{ item.shopNum || 0 }}家门店可拍
				      </view>
				    </view>
				  </view>
				</view>
				<view style="height: env(safe-area-inset-bottom);"></view>
			</scroll-view>
</template>

<script>
export default {
        data(){
            return{
              
            }
        }
        methods(){
            getList(){
				this.$u.api.getSampleSeriesList({xxx:1}).then(result => {
					console.log(result,'result')
					let array = result.rows
					for (let s of array) {
						this.sampleList.push(s)
					 console.log(	this.sampleList,'	this.sampleList')
					}
					this.total = result.total
				}).catch(error => {
					console.error('请求失败:', error);
				});
			},
toPage(item) { 
		  uni.navigateTo({ url: item });  
		}
        }
}
</script>

<style>
相关推荐
天远数科7 分钟前
风险治理实战:基于天远车信盟出险构建自动化理赔核保流水线
java·网络·人工智能·自动化
yume_sibai9 分钟前
Element Plus 数据展示组件完全指南(15个核心组件)
前端·javascript·vue.js
Mr.朱鹏33 分钟前
Linux 服务器 LVM 根分区在线动态扩容
linux·服务器·数据库
骇客野人34 分钟前
SpringBoot电商系统用户注册、登录、留存及数据埋点设计与落地实施方案
java·spring boot·后端
qiuhaipeng141 分钟前
Claude code 升级后上下文长度变短问题
java·前端·数据库
mengge.cloud1 小时前
存储技术基础小白教程
linux·运维·服务器·wpf·存储
zzz_23681 小时前
个人 AI 记忆如何跨工具复用:用 Markdown、索引和 Skill 搭一个可治理的记忆库
前端·人工智能·react.js·前端框架·agent·agent测评
wxwx_bscxy3221 小时前
基于Python新冠疫情可视化分析系统的设计与实现
java·数据库·spring boot·python·微信小程序·sqlite
tang777892 小时前
反爬虫场景下代理IP池的动态扩容与失效IP自动清理方案实现
linux·服务器·网络·爬虫代理·住宅代理ip
剑之所向2 小时前
.NET 官方`System.Threading.Channels`
前端·javascript·数据库