0
点赞
收藏
分享

微信扫一扫

微信小程序使用公共方法实现转发功能


util.js文件

const share = res =>{
if (res.from === 'menu') {
console.log(res);// 来自页面内转发按钮
}
return {
title: '您的好友向您推荐了好玩的小程序,快来看看吧',
path: '/pages/user/user',
imageUrl:'/images/share.jpg',
success: function(res) {
console.log('转发成功');// 转发成功
},
fail: function(res) {
console.log('转发失败');// 转发失败
}
}
}
module.exports = {
share:share,
}



index.js  -页面,引入了util.js文件,并调用util.share这个方法


//获取应用实例
const app = getApp()
const util = require('../../utils/util.js');

Page({
data: {
motto: 'Hello World',
userInfo: {},
hasUserInfo: false,
canIUse: wx.canIUse('button.open-type.getUserInfo')
},
onLoad: function () {

getUserInfo:


举报

相关推荐

0 条评论