收藏
回答

为什么我的mainname参数传到pgdetail页面是空值呢?

<view class="page">
<view class="page__bd">
<view class="weui-panel weui-panel_access">
 <view class="weui-panel__hd">{{secname}}</view>
<block wx:for="{{soundprogram}}" wx:if="{{secname == item.secname}}" >
<view class="weui-panel__bd">
<navigator url="/pages/pgdetail/pgdetail?mainname={{encodeURIComponent(item.mainname)}}" class="weui-media-box weui-media-box_appmsg" hover-class="weui-cell_active">
 <view class="weui-media-box__hd weui-media-box__hd_in-appmsg">
  <image class="weui-media-box__thumb" src="{{item.cover}}" />
    </view>
  <view class="weui-media-box__bd weui-media-box__bd_in-appmsg">
 <view class="weui-media-box__title">{{item.mainname}}</view>
 <view class="weui-media-box__desc">{{item.describe}}</view>
  </view>
 </navigator>
</view>
</block>
 </view>
</view>
</view>



// pages/pgdetail/pgdetail.js
Page({
   data: {
     },
 onLoadfunction(options{
    console.log(options); // 打印整个options对象
    // 解码传入的mainname参数
    const mainname = decodeURIComponent(options.mainname);
    // 设置导航栏的标题
    wx.setNavigationBarTitle({
      title: mainname
    });
  },
})

最后一次编辑于  03-24
回答关注问题邀请回答
收藏
登录 后发表内容