微信小程序商品到详情

微信小程序商品到详情结构代码资源分享给大家.

商品页 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. })

转载于:https://my.oschina.net/u/3396785/blog/994182

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值