微信小程序知识

从A页面跳转到B页面

A页面 wxml文件代码

<view bindtap="detail" data-id="" data-name=""></view> ////bindtap绑定事件

 A页面的js文件代码

onLoad:function(){

detail:function(res){

console.log(res);//res bindtap绑定传的参数

wx.navigateTo({ url:'../detail/detail?id='+res.currentTarget.id+'&amp;title='+res.currentTarget.title,//B页面的地址 //修改哪个页面的标题就是哪个页面的json文件中修改,如 a页面 a.json中修改{"navigationBarTitleText":"我是A页面的标题哦"}

}) } }

B 页面中的B.js中的中拿到A页面传的值

onLoad:function(options){

console.log(console.log)

//发请求拿数据

var that = this;

vx.setNavigationBarTitle({ text:option.name })// //当前页面的标题

wx.request({

'url':'http://192.168.1.43/detail.php?id='+option.id,

success:function(res){

console.log(res)

that.setData({films:res.data}) } })

}

//进入小程序数据加载的慢的问题,

在app.js中添加wx.showLoading函数,数据未加载出会有请求数据中的图片

App({ onLaunch:function(){ //中加入 wx.showLoading({ title:'请求数据中', }) } })

在a页面中如果请求接口拿数据成功后把加载中的图标关闭 wx.hideLoading()

世界上最美的风景,是自己努力的模样
原文地址:https://www.cnblogs.com/xiong-hua/p/13284986.html