navigate里面可以使用for吗,或者给list里面的图片每一个对应跳转页面怎么做?

小程序 文章 2022-03-16 17:40 569 0 全屏看文

AI助手支持GPT4.0

navigate里面可以使用for吗,或者给list里面的图片每一个对应跳转页面怎么做?Can I use for in navigate, or what to do for each corresponding jump page of the pictures in the list?

navigate里面可以使用for吗,或者给list里面的图片每一个对应跳转页面怎么做?


我这想用for,但是报错,是不是这里不能用呀(纯新手做毕设)

I want to use for, but I report an error. Can't I use it here

回答:

八九:

navigate可以,点击跳转也可以

.:

1,把for循环的view标签换为navigator标签

https://developers.weixin.qq.com/miniprogram/dev/componentavigator.html

2,给点击事件绑定一个data-id="item.id"

click(e){  console.log(e.currentTarget.dataset.id) //拿到参数  // 使用wx.navigateTo或者其他,跳转到指定页面并传参}


https://developers.weixin.qq.com/miniprogram/dev/apioute/wx.navigateTo.html

任性༄🍎:

navigator 标签肯定能用for循环,或者你把错误贴出来?

-EOF-

AI助手支持GPT4.0