1、微信小程序當前頁面不可轉(zhuǎn)發(fā)如何解決
1、當小程序當前頁面不可轉(zhuǎn)發(fā)時,首先查看當前文件的js文件中,是否添加了 onShareAppMessage 事件,若沒有,則不能正常轉(zhuǎn)發(fā),這時添加上 onShareAppMessage 事件即可文章來源:http://www.zghlxwxcb.cn/news/detail-540220.html
// index.js
const app = getApp()
const api = require("../../api/index.js").API
// 獲取應用實例
Page({
data: {
tabList: ['推薦','案例','法規(guī)','實操'],
tabIndex: 0,
content: "",
inputValue: "",
statusBarHeight: app.globalData.statusBarHeight+10,
id: null,
token: null,
productTypeId: null
},
onLoad:function(options) {
console.log(this.data.statusBarHeight,'statusBarHeight')
if (wx.getUserProfile) {
this.setData({
canIUseGetUserProfile: true
})
}
if(options.token) {
wx.setStorageSync('y-token', options.token)
}
this.setData({
token: wx.getStorageSync('y-token') ? wx.getStorageSync('y-token') : null
})
// this.getProduct()
},
onShow:function() {
this.getProduct()
},
linkMini() { //點擊稅可知跳轉(zhuǎn)到稅可知小程序
let token = wx.getStorageSync('y-token') ? wx.getStorageSync('y-token') : null
wx.navigateToMiniProgram({
appId: 'wx7fa35467842f00b4',
path: 'pages/index/index?token='+token,
envVersion: 'develop' //體驗版 trial 正式 release
})
},
tabClick(e) { //tab點擊事件
this.setData({
tabIndex: e.currentTarget.dataset.index
})
},
/**
* 用戶點擊右上角分享
*/
onShareAppMessage: function () {
}
})
或者通過 onShareAppMessage 函數(shù)設置分享標題等信息文章來源地址http://www.zghlxwxcb.cn/news/detail-540220.html
onShareAppMessage: function (options) {//分享
return {
title: this.data.pageData.name,
path: `packageA/pages/bossDet/bossDet?id=${this.data.id}`,
success: function (res) {
console.log(res,'成功')
console.info(res + '成功');
wx.showToast({
title: '分享成功',
})
// 轉(zhuǎn)發(fā)成功
},
fail: function (res) {
console.log(res + '失敗');
// 轉(zhuǎn)發(fā)失敗
},
complete: function (res) {
// 不管成功失敗都會執(zhí)行
console.log(res,'成功或失敗')
wx.showToast({
title: '成功或失敗',
})
}
}
},
到了這里,關于微信小程序當前頁面不可轉(zhuǎn)發(fā)如何解決的文章就介紹完了。如果您還想了解更多內(nèi)容,請在右上角搜索TOY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關文章,希望大家以后多多支持TOY模板網(wǎng)!