In addition to Weibo, there is also WeChat
Please pay attention

WeChat public account
Shulou
2025-11-02 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly explains "how to encapsulate JS Wechat sharing", interested friends may wish to have a look. The method introduced in this paper is simple, fast and practical. Next, let the editor take you to learn how to encapsulate JS Wechat sharing.
My train of thought:
1. Can share to four places QQ, friends, moments, Weibo, generally they are the same, you can configure an initial parameter, assign values to them four
two。 If there is an inconsistency, because the initial parameters have been assigned previously, replace the content that needs to be inconsistent.
Implement the main code:
SetData: function () {var self = this Self.data = {title: self.title, desc: self.desc, link: self.link, imgUrl: self.imgUrl, type: self.type, / / sharing type, music, video or link. If left empty, the default is link dataUrl: self.dataUrl, / / if type is music or video, provide a data link Default is empty success: self.success, cancel: self.cancel} / / Deep cloning self.QQData = JSON.stringify (self.data); self.QQData = JSON.parse (self.QQData); self.TimeLineData = JSON.stringify (self.data); self.TimeLineData = JSON.parse (self.TimeLineData); self.WeiBoData = JSON.stringify (self.data); self.WeiBoData = JSON.parse (self.WeiBoData) / / deserialize self.QQData.success = self.success; self.TimeLineData.success = self.success; self.WeiBoData.success = self.success; self.QQData.cancel = self.cancel; self.TimeLineData.cancel = self.cancel; self.WeiBoData.cancel = self.cancel;} wx.ready (function () {wx.showOptionMenu () If (self.data = ='') self.setData (); wx.onMenuShareQQ (self.QQData); wx.onMenuShareAppMessage (self.data); wx.onMenuShareTimeline (self.TimeLineData); wx.onMenuShareWeibo (self.WeiBoData);})
Use help:
Var wxshare = require ('wxshare.js')
If the shared content is the same
Wxshare.link ='; wxshare.desc =''; wxshare.imgUrl =''; wxshare.type =''; wxshare.dataUrl =''; wxshare.start ()
If there are inconsistencies, make changes to the inconsistencies
Wxshare.link ='; wxshare.title =''; wxshare.desc ='; wxshare.imgUrl =''; wxshare.setData (); / / must add wxshare.TimeLineData.title =''; wxshare.QQData.desc =''; wxshare.start ()
Key note: setData ()
If all the shared contents are the same, execute start () directly, and determine that the data parameter is empty to true, and setData () will be executed.
Assign values to four shares: QQData data TimeLineData WeiboData, and then initialize
If there is any inconsistency, after the assignment, call setData () directly to assign values to the four parameters, and then modify the corresponding parameters according to the requirements, and initialize them with * start ().
At this point, I believe you have a deeper understanding of "how to encapsulate JS Wechat sharing". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

The market share of Chrome browser on the desktop has exceeded 70%, and users are complaining about
The world's first 2nm mobile chip: Samsung Exynos 2600 is ready for mass production.According to a r
A US federal judge has ruled that Google can keep its Chrome browser, but it will be prohibited from
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope





About us Contact us Product review car news thenatureplanet
More Form oMedia: AutoTimes. Bestcoffee. SL News. Jarebook. Coffee Hunters. Sundaily. Modezone. NNB. Coffee. Game News. FrontStreet. GGAMEN
© 2024 shulou.com SLNews company. All rights reserved.