码迷,mamicode.com
首页 > 微信 > 详细

微信小程序知识

时间:2020-07-11 19:19:40      阅读:92      评论:0      收藏:0      [点我收藏+]

标签:let   标题   fun   nload   func   res   数据   art   current   

从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()

微信小程序知识

标签:let   标题   fun   nload   func   res   数据   art   current   

原文地址:https://www.cnblogs.com/xiong-hua/p/13284986.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!