微信小程序商品到详情

原文链接: https://my.oschina.net/u/3396785/blog/994182

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

商品页 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. {{article.title}}
  2. {{article.content}}
  3. {{article.collection}}
  4. {{article.reading}}

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

你可能感兴趣的:(微信小程序商品到详情)