微信小程序商品到详情(传参)

商品页 post.wxmldata-postid=”{{index}}view class=”container” swiper indicator-dots indicator-color=”rgba(255,255,255,0.3)” indicator-active-color=”rgba(255,255,255,1)” autoplay swiper-item image src= …

     

商品页 post.wxml

data-postid=”{{index}}

 


  1. <view class="container">
  2. <swiper indicator-dots indicator-color="rgba(255,255,255,0.3)" indicator-active-color="rgba(255,255,255,1)" autoplay>
  3. <swiper-item>
  4. <image src="/dist/images/wx.png"></image>
  5. </swiper-item>
  6. <swiper-item>
  7. <image src="/dist/images/vr.png"></image>
  8. </swiper-item>
  9. <swiper-item>
  10. <image src="/dist/images/iqiyi.png"></image>
  11. </swiper-item>
  12. </swiper>
  13. <view class="article-list">
  14. <view class="article" wx:for="{{postList}}" wx:for-item="article" wx:key="index" catchtap="goDetail" data-postid="{{index}}">
  15. <view class="article-author-date">
  16. <image src="{{article.avatar}}" class="article-author"></image>
  17. <text class="article-date">{{article.date}}</text>
  18. </view>
  19. <text class="article-title">{{article.title}}</text>
  20. <image src="{{article.imgSrc}}" class="article-image"></image>
  21. <text class="article-content">
  22. {{article.content}}
  23. </text>
  24. <view class="article-link">
  25. <image src="/dist/images/icon/chat1.png"></image>
  26. <text>{{article.collection}}</text>
  27. <image src="/dist/images/icon/view.png"></image>
  28. <text>{{article.reading}}</text>
  29. </view>
  30. </view>
  31. </view>
  32. </view>

 

post.js

en对象获取postid

 


  1. var postData = require ("../../data/posts-data.js");
  2. Page({
  3. onLoad:function(){
  4. this.setData({
  5. postList:postData.postList
  6. })
  7. },
  8.  
  9. goDetail:function(en){
  10.  
  11. var postid = en.currentTarget.dataset.postid;
  12. wx.navigateTo({
  13. url:"post-detail/post-detail?postId="+postid
  14. })
  15. }
  16. })

 

商品详情页 post-detail.js

用option接收postid

 


  1. var postData = require("../../../data/posts-data.js");
  2. Page({
  3. onLoad:function(option){
  4. console.log(option);
  5. }
  6. })

免责声明:本站所有文章和图片均来自用户分享和网络收集,文章和图片版权归原作者及原出处所有,仅供学习与参考,请勿用于商业用途,如果损害了您的权利,请联系网站客服处理。

【小程序源码网资源版权风险说明】:
本站为避免不必要的纷争,分享的所有资源中一切可能有版权风险的资源将全部转载自第三方网站或平台,站长只为大家提供相关资源的介绍和跳转引导。 因可能有疏忽大意,所以如有遗漏资源侵犯了您的合法权利,请联系站长删除。
【小程序源码网资源下载使用说明】:
本站所分享的一切QQ小程序源码,thinkphp整站源码,微信小程序源码,图文教程等资源仅供用户学习参考使用,任何人不得作其他用途,违者自行承担所有责任。
【小程序源码网毫无人看的介绍】:
本站又称Z站,原名贼娘网,开站于2018年,换过三任站长,目前站长是第四任站长,本站是一个主要分享免费开源小程序源码/网站源码/免费素材/教程资源的网站,主要小程序资源有用于学习的小程序源码,也有正版原创可商用的小程序源码,是一个公益博客型网站。
【小程序源码网原创源码版权申明】:
未经小程序源码网许可,任何人不得擅自使用本站原创首发源码进行商业行为(除本站VIP用户在期限内,版权无使用限制),否则将依法承担相应赔偿责任。
【小程序源码网转载文章版权申明】:
本站所转载的QQ小程序或微信小程序源码与其他资源仅供学习,任何人不得作其他用途,违者自行承担所有责任。
【小程序源码网站长最后的屁话】:
如有您认为本站有任何侵犯您合法权益的文章,或者您有什么疑问需求,欢迎联系站长QQ,站长24小时在线,备注公司名称和源码版权问题或者需要小程序定制开发等站长业务类型可急速处理,如果您只是交流小程序的一些开发问题或源码问题可以加入QQ群讨论,就不用加站长啦,对于白嫖党,QQ群才是处理问题的天堂,当然站长也欢迎大家骚扰~
小程序源码网 » 微信小程序商品到详情(传参)
嘿,投喂下嘛!