当前位置:网站首页>Wechat applet - all pages turn on the sharing circle of friends function at one time (only need to be executed once) (wx.showsharemenu)
Wechat applet - all pages turn on the sharing circle of friends function at one time (only need to be executed once) (wx.showsharemenu)
2022-07-20 09:22:00 【Amnesia�】
Take the function of sharing a circle of friends as an example , If you want to open the page, you can share ,
Must call... On this page wx.showShareMenu(), The share circle of friends button is activated .
Suppose all the pages of my applet need to be shared , Then all my pages need to call ( Tired and hard to maintain ),
To solve this problem , It only needs to be executed once Code , You can set all the pages .
Solution
utilize wx.onAppRoute API, Listening route jump completed , Direct automatic execution wx.showShareMenu()
Open the project app.js file , Follow the code below , Just write your project .
App({
// Call... On initialization
onLaunch: function () {
this.overShare()
},
/** * Turn on the sharing function of the circle of friends * @description Monitor route switching / Automatic execution * @return void */
overShare() {
wx.onAppRoute((res) => {
// console.log('route', res)
let pages = getCurrentPages()
let view = pages[pages.length - 1]
if(view) {
wx.showShareMenu({
menus: ['shareAppMessage', 'shareTimeline'],
success(res) {
},
fail(e) {
}
})
}
})
},
})
边栏推荐
- 变量和简单的数据类型
- Uniapp wechat applet sharing and friend circle sharing function
- Array common methods, principle simulation, and high order of common functions
- Opencv image bit operation
- yolov4和v5
- float position
- 硬件电路PCB设计——布线注意(1)
- H5页面导出成pdf文件
- Horizontal comparison between distributed transaction framework Seata and Hmily
- Introduction to vLQ
猜你喜欢
模拟图像加密、解密
new URLSearchParams() 内置对象获取地址栏的参数 通过键的方式拿到值
OpenCV图像位运算
H5 page export to PDF file
New urlsearchparams() the built-in object gets the parameters of the address bar and gets the value by means of keys
Crack detection of pytoch migration learning Version (resnet50)
对于因果模型的常见评估函数:SHD 和 FDR
Array 常用方法原理模拟,以及常用函数高阶
MySQL log module
【mindspore】【import erro】 undefined symbol _Z14DlogErrorInneriPK
随机推荐
LSTM stock price forecast pytorch
H5 page export to PDF file
yolov2
[deep learning] - model comparison of emotional analysis of IMDB data set (4) - cnn-lstm integrated model
Introduction to vLQ
yolov3
单片机1-流水灯
灯光模拟小程序
uniapp小程序底部弹出窗口
微信小程序获取uni.showActionSheet中选择的值
Yolov4 and V5
电源学习(2)——基本元件
yolov1
对于因果模型的常见评估函数:SHD 和 FDR
微信小程序 - 所有页面一次性(只需要执行一次)全部开启分享朋友圈功能(wx.showShareMenu)
电源学习(1)——电源系统测试
js object相加_js 对象数组属性相同的值合并相加
通过JS将图片File转为base64并压缩
Talk about redis cache deletion strategy
Asp.NET <%=%> <%#%> <% %> <%@%>