利用豆瓣api写个小程序(小程序笔记)2 如何跳转页面

落花浮王杯 提交于 2019-11-30 01:07:04
  1. 小程序的页面跳转
 <button bindtap="gotoComment" data-movieid="{{item.id}}" class="movie-comment">评价</button>
.movie-comment{
  height: 60rpx;
  background: #e54847;
  color: #fff;
  font-size: 26rpx;
  margin-top: 120rpx;
}

添加评价按钮,跳转到详情

添加gotoComment方法

 gotoComment:function(event){
    wx.navigateTo({
      url: `../comment/comment?movieid=${event.target.dataset.movieid}`
    });
    
  }
event.target.dataset获取到交互的变量,wx.navigateTo的使用说明见微信开发文档 https://developers.weixin.qq.com/miniprogram/dev/api/route/wx.navigateTo.html
 
跳转后如何获取到参数?
在跳转后的新页面里
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    console.log(options);//options对象里就有movieid
  },

 


易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!