当前位置: 首页 > Web前端 > JavaScript

uniapp分享给朋友,分享朋友圈(带参数),无法传递参数-无法获取参数

时间:2023-03-26 23:00:52 JavaScript

分享给朋友/分享到群聊分享给朋友/分享去群聊具体的js代码//data中定义的参数/*data(){return{item:{name:'13',value:'234234'}}}*/onShareAppMessage(e){console.log(e)if(e.from=='button'){//点击按钮按钮分享//做某事}if(e.from=='menu'){//点击右上角...button(three-dotbutton)shared//dosomething}//获取按钮传入的参数data中的item值letparams=e.target.dataset.obj//获取data中定义的item值return{title:'CarRentalDetails',path:`/pages/login/login?id=123&name=WangChuanchuan`//固定参数//path:`/pages/login/login?id=${this.info.id}&name=${this.name}`//动态参数}},分享到朋友圈有两种方式:(总有一种可以得到)1.网上找不到参数e2.我用的是Whatcanbegetting//两种方法的区别只是查询中传递参数的方法//我用的是可以获取参数的方法(如下:)onShareTimeline(){letid='9999'letname='景传串'return{title:'租车',//标题路径:'/pages/login/login',//分享路径query:'id=342&name=王串串&type=朋友圈',//query:`id=${this.info.id}&openId=${this.openId}&type=Moments`,//动态参数1//query:"id="+id+"&name="+name,//"goodId=456&d=123"imageUrl:'https://cdn.uviewui.com/uview/swiper/1.jpg'//分享图片};}//网上找的传参方法获取不到参数(如下:)onShareTimeline(){return{title:'租车',//标题路径:'/pages/login/login',//分享路径查询:{id:'234324',name:'王川川',age:'57'},imageUrl:'https://cdn.uviewui.com/uview/swiper/1.jpg'//分享图片};}获取参数:(在onLoad或onShow中获取)-----onShareAppMessage也是在这里获取onLoad(options){console.log(options)},页面参数如下:(打印结果)