When sharing on WeChat, the parameters of the sharing link may not be fixed. You need to know it just before sharing. This is the basic way to dynamically set up the sharing link. The code is not so detailed, but the general process is as follows.
1. Install and reference jssdk
npm install --save weixin-js-sdk const wx=require('weixin-js-sdk')
2. Inject configuration information through the config interface
const jsApiList = ['onMenuShareQQ', 'onMenuShareAppMessage', 'onMenuShareTimeline', 'updateAppMessageShareData', 'updateTimelineShareData']
Methods in methods
getUrl () { if ( === '') { = ('#')[0] } var u = var isAndroid = ('Android') > -1 || ('Linux') > -1 // g return isAndroid ? ('#')[0] : }, getConfig () { var url = () return new Promise((resolve, reject) => { this.$('your requestUrl', { params: { url: url } }).then((response) => { var data = var appId = var noncestr = // var jsapi_ticket = res.jsapi_ticket; var timestamp = var signature = ({ debug: false, // Turn on debug mode, the return values of all APIs called will be alerted on the client. To view the passed parameters, you can open them on the PC side. The parameter information will be printed through the log and will only be printed on the PC side. appId: appId, // Required, the unique identification of the official account timestamp: timestamp, // Required to generate a signature time stamp nonceStr: noncestr, // Required to generate a random string of signatures signature: signature, // Required, signature, see Appendix 1 jsApiList: jsApiList // Required, list of JS interfaces that need to be used, and list of all JS interfaces see Appendix 2 }) (function (res) { ((res)) }) resolve() }) }) }, shareToFriendsCircle () { (() => { ({ title: , link: , imgUrl: , success: function () { } }) }) }, shareToFriends () { (() => { ({ title: , desc: , link: , imgUrl: , success: function () { } }) }) },
Calling the getConfig method in mounted
The location code for calling the sharing method is roughly as follows
= + '/****/#/share?openId=' + + '&shareId=' + shareId = 'Share link to add dynamic parameters' () ()
Summarize
The above is the method of adding dynamic parameters to vue to WeChat sharing links introduced by the editor. I hope it will be helpful to everyone. If you have any questions, please leave me a message and the editor will reply to everyone in time. Thank you very much for your support for my website!
If you think this article is helpful to you, please reprint it. Please indicate the source, thank you!