点击列表,根据不同Id (参数)进入详情页

第一步:请求你要的参数
第二步:跳转时把这个参数绑定在循环上
第三步:实现功能,点击跳转对应页面
第四步:接受参数使用

第一步:请求

				this.$http.get('', {
					station_id: 2745,
				}).then(res => {
					if (res.data.result === 1) {
						let server = res.data.data;
						server.list.forEach(item => {
							this.baconlist.push({
								meter_id: item.meter_id, //传递的参数
							})
						})
					} else {
						uni.showToast({
							icon: 'none',
							title: '没有数据'
						})
					}
				})
		

第二步:给页面上循环绑定值

		<view class="contentblocks" v-for="(item,index) in baconlist">
			<view class="bacon-btn">
				<!--跳转时传递的参数是item.meter_id,跳转方法:goinfo()-->
				<u-button @tap="goinfo(item.meter_id)">查询</u-button>
			</view>
		</view>

第三步:实现跳转功能

			goinfo(meterid) {
				console.log('仪表id'+meterid)
				uni.navigateTo({
					//meterid要在下个页面,通过option接受这个参数
					url: `../XXX/XXX?meterid=${meterid}`
				})
			}

接受参数的页面(第四步)

	//Page:newPage

		onLoad(option) {
			this.meterid = option.meterid; //页面data定义一个meterid接受参数,用作本地值使用
			console.log(this.meterid)
		}
  • 2
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
以下是一个简单的示例代码,可以根据你的具体情况进行修改和调整。 在你的商品列表页面,当用户点击某个商品图片时,你可以在启动商品详情页面的 Intent 传递一些参数,如下所示: ```java // 定义启动商品详情页面的 Intent Intent intent = new Intent(this, ProductDetailActivity.class); // 将商品的图片、价格和标题等信息作为参数传递给详情页面 intent.putExtra("product_image", bitmap); intent.putExtra("product_price", price); intent.putExtra("product_title", title); startActivity(intent); ``` 在你的商品详情页,你可以从 Intent 获取这些参数,并将它们显示在相应的控件上,如下所示: ```java // 从 Intent 获取商品的图片、价格和标题等信息 Bitmap bitmap = getIntent().getParcelableExtra("product_image"); String price = getIntent().getStringExtra("product_price"); String title = getIntent().getStringExtra("product_title"); // 将商品的图片显示在 ImageView 控件上 ImageView imageView = findViewById(R.id.product_image_view); imageView.setImageBitmap(bitmap); // 将商品的价格和标题分别显示在 TextView 控件上 TextView priceView = findViewById(R.id.product_price_text_view); priceView.setText(price); TextView titleView = findViewById(R.id.product_title_text_view); titleView.setText(title); ``` 其,`R.id.product_image_view`、`R.id.product_price_text_view` 和 `R.id.product_title_text_view` 是你在商品详情页面上定义的对应控件的 ID。你需要根据实际情况进行修改。 注意,上面的示例代码,我们将商品的图片传递给详情页面的方式是将 Bitmap 对象直接作为 Intent 的附加信息传递。这种方式可能导致传递的数据量过大,影响应用的性能。如果你需要传递大量的数据,建议使用其他方式,如将数据保存到本地文件或数据库,然后在详情页面从文件或数据库读取。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值