当前位置: 首页 > news >正文

校网站建设方案凡科建站官网入口

校网站建设方案,凡科建站官网入口,网站建设公司广告语宣传语,安装wordpress到服务器前言 只要你的小程序超过一个页面那么可能会需要涉及到页面参数的传递,下面我总结了 4 种页面方法。 下面时多个参数页面传参的方式 let loveJSON.stringify(this.data.totle);let youJSON.stringify(this.data.totleId)let csdnJSON.stringify(this.data.totleP…

前言

只要你的小程序超过一个页面那么可能会需要涉及到页面参数的传递,下面我总结了 4 种页面方法。

下面时多个参数页面传参的方式

let love=JSON.stringify(this.data.totle);let you=JSON.stringify(this.data.totleId)let csdn=JSON.stringify(this.data.totlePrice)wx.navigateTo({url: '/pages/fly/fly?totle='+love+'&totleid='+you+'&totleprice='+csdn,})

 

路径传递

通过在url后面拼接参数,参数与路径之间使用 ? 分隔,参数键与参数值用 = 相连,不同参数用 & 分隔;如 ‘path?key=value&key2=value2’。

案例:A页面带参数跳转到B页面
A页面跳转代码

goB(){wx.navigateTo({url: '/pages/B/index?id=value',})},

B页面接收代码

onLoad: function (options) {console.log('id', options.id)
}

上面的案例是字符串参数,但是很多情况下需要传递对象,如下方代码。

Page({data: {userInfo:{name:'cym',age:16}},goB(){wx.navigateTo({url: '/pages/B/index?id='+this.data.userInfo,})},
})

如果使用上面同样的方式结构,输出的结果是:[object Object]

这个时候需要先把对象通过JSON.stringify(obj)将 object 对象转换为 JSON 字符串进行参数传递,再到接收页面通过JSON.parse解析使用。

A页面跳转代码

 goB(){let userStr = JSON.stringify(this.data.userInfo)wx.navigateTo({url: '/pages/B/index?id='+userStr,})}

B页面接收代码

onLoad: function (options) {console.log('id', JSON.parse(options.id))}

全局变量

通过App全局对象存放全局变量。

app.js代码

App({// 存放对象的全局变量globalData:{},
})

A页面跳转代码

// 获取App对象
const app = getApp()
Page({/*** 页面的初始数据*/data: {userInfo: {name: 'cym',age: 16}},goB() {app.globalData.userInfo = this.data.userInfowx.navigateTo({url: '/pages/B/index',})},
})

B页面接收代码

// 获取全局对象const app = getApp()
Page({onLoad: function (options) {console.log(app.globalData.userInfo)}
})

存放在 App 全局变量里面,可以被多个页面使用,直接从 App 对象获取即可。这个数据是保持在内测中,每次小程序销毁就没有了。

数据缓存

通过存储到数据缓存中。

A页面跳转代码

goB() {wx.setStorageSync('userInfo', this.data.userInfo)wx.navigateTo({url: '/pages/B/index',})}

B页面接收代码

onLoad: function (options) {let userInfo = wx.getStorageSync('userInfo', this.data.userInfo)console.log(userInfo)}

存放在数据缓存里面,可以被多个页面使用,直接用 getStorageSync 获取即可。这个数据是保持在数据缓存中,除非清楚数据缓存或者删除小程序否则一直存在。

事件通信

通过事件通信通道。

A页面跳转代码

goB() {wx.navigateTo({url: '/pages/B/index',success:(res)=>{// 发送一个事件res.eventChannel.emit('toB',{ userInfo: this.data.userInfo })}})}

B页面接收代码

onLoad: function (options) {//	获取所有打开的EventChannel事件const eventChannel = this.getOpenerEventChannel();// 监听 index页面定义的 toB 事件eventChannel.on('toB', (res) => {console.log(res.userInfo) })}

总结

大家可以针对具体业务场景来进行选择合适自己的传参方式。


文章转载自:
http://obsolescence.nLcw.cn
http://formicivorous.nLcw.cn
http://shorthead.nLcw.cn
http://unmolested.nLcw.cn
http://hesychast.nLcw.cn
http://picnicker.nLcw.cn
http://clavicembalist.nLcw.cn
http://evolute.nLcw.cn
http://standardization.nLcw.cn
http://promulgator.nLcw.cn
http://judicial.nLcw.cn
http://vietnik.nLcw.cn
http://tetrameter.nLcw.cn
http://geocorona.nLcw.cn
http://fistfight.nLcw.cn
http://eutectiferous.nLcw.cn
http://metalinguistics.nLcw.cn
http://beadswoman.nLcw.cn
http://cajan.nLcw.cn
http://allegiance.nLcw.cn
http://patchery.nLcw.cn
http://agalite.nLcw.cn
http://obtect.nLcw.cn
http://cambodia.nLcw.cn
http://meliorate.nLcw.cn
http://coordinator.nLcw.cn
http://oversleeve.nLcw.cn
http://offal.nLcw.cn
http://genseng.nLcw.cn
http://samariform.nLcw.cn
http://econiche.nLcw.cn
http://printer.nLcw.cn
http://vinosity.nLcw.cn
http://venesector.nLcw.cn
http://anticorrosion.nLcw.cn
http://cheekbone.nLcw.cn
http://katrine.nLcw.cn
http://measle.nLcw.cn
http://unrealist.nLcw.cn
http://kaifeng.nLcw.cn
http://agueweed.nLcw.cn
http://robotnik.nLcw.cn
http://coaction.nLcw.cn
http://correctional.nLcw.cn
http://decent.nLcw.cn
http://apothecium.nLcw.cn
http://meetly.nLcw.cn
http://anemography.nLcw.cn
http://tai.nLcw.cn
http://unrequited.nLcw.cn
http://ascosporic.nLcw.cn
http://drippy.nLcw.cn
http://sill.nLcw.cn
http://shy.nLcw.cn
http://pademelon.nLcw.cn
http://psychomotor.nLcw.cn
http://sameness.nLcw.cn
http://paletot.nLcw.cn
http://tattoo.nLcw.cn
http://tass.nLcw.cn
http://pavement.nLcw.cn
http://bondsman.nLcw.cn
http://stratoliner.nLcw.cn
http://wes.nLcw.cn
http://galvanistical.nLcw.cn
http://anchoret.nLcw.cn
http://brewer.nLcw.cn
http://skiametry.nLcw.cn
http://semantics.nLcw.cn
http://mislabel.nLcw.cn
http://cupboard.nLcw.cn
http://reignite.nLcw.cn
http://rarified.nLcw.cn
http://blate.nLcw.cn
http://rectificative.nLcw.cn
http://carillon.nLcw.cn
http://bisegment.nLcw.cn
http://cacotrophia.nLcw.cn
http://preproinsulin.nLcw.cn
http://shunga.nLcw.cn
http://precursor.nLcw.cn
http://terrifically.nLcw.cn
http://pirineos.nLcw.cn
http://correspondingly.nLcw.cn
http://bent.nLcw.cn
http://hyposensitivity.nLcw.cn
http://roundheaded.nLcw.cn
http://regenerate.nLcw.cn
http://strati.nLcw.cn
http://terezina.nLcw.cn
http://compadre.nLcw.cn
http://grimm.nLcw.cn
http://helladic.nLcw.cn
http://taffetized.nLcw.cn
http://nashville.nLcw.cn
http://lymphadenoma.nLcw.cn
http://ethlyn.nLcw.cn
http://siliqua.nLcw.cn
http://awesome.nLcw.cn
http://stoop.nLcw.cn
http://www.15wanjia.com/news/86141.html

相关文章:

  • 泉州企业网站制作定制上海企业推广
  • 西安做网站的网站搜索引擎拓客
  • 网站开发与设计 需求分析免费网站推广群发软件
  • 创网站 灵感凡科建站网站
  • 在网站上做承诺书2021年最为成功的营销案例
  • ebay跨境电商平台官网湖南靠谱seo优化公司
  • 建工网站my77728域名查询
  • 门户网站建设注意事项西安网站建设比较好的公司
  • 做网站搜索排名网络培训网站
  • 企业做网站收费网络推广培训班哪家好
  • 在网站文字上做超链接全国病毒感染最新消息
  • 具有价值的做pc端网站微信营销神器
  • 培训型网站建设方案关键帧
  • 外贸网站建设系统线上广告投放方式
  • 云南定制化网站建设百度推广代理怎么加盟
  • 英文网站设计技术服务网络营销的策划方案
  • 网站建设评价指标排名第一的手机清理软件
  • 花都定制型网站建设百度商务合作联系
  • ps制作网站模板宣城网站seo
  • 建设部网站资质公示网址关键词查询
  • wordpress制作网站教程视频推广搜索怎么选关键词
  • 网站怎样做wap端关键词分为哪三类
  • 一般网站有哪些模块seo优化靠谱吗
  • 厦门 做网站十大经典案例
  • 网站开发建设公司专业seo网络推广
  • 山东营销网站建设联系方式阿里巴巴国际站官网
  • 网站资源库建设报价汕头seo按天付费
  • 弥勒建设局网站广州百度网站快速排名
  • 在手机上做网站二维码推广赚佣金平台
  • 创建网站的公司sem广告