Vue implements the method of sharing other pages on the current page
This article mainly introduces the WeChat sharing function of vue in detail. Vue implements the current page to share other pages, which has a certain reference value. Interested friends can refer to it. I hope it can help everyone.
The example in this article shares the specific code for vue WeChat sharing and display for your reference. The specific content is as follows
First, take sharing with friends as an example
1 , first read the official document
wx.onMenuShareAppMessage({ title: '', // 分享标题 desc: '', // 分享描述 link: '', // 分享链接,该链接域名或路径必须与当前页面对应的公众号JS安全域名一致 imgUrl: '', // 分享图标 type: '', // 分享类型,music、video或link,不填默认为link dataUrl: '', // 如果type是music或video,则要提供数据链接,默认为空 success: function () { // 用户确认分享后执行的回调函数 }, cancel: function () { // 用户取消分享后执行的回调函数 } });
2. Pitfalls in vue sharing
* 1. Get dynamic url
in WeChat sharing * 2. WeChat secondary sharing automatically adds parameters form=singlemessage
* 3. Each page in vue can call sharing
3. Direct code analysis
In order to ensure Each page can activate WeChat sharing. You need to add watch monitoring
Code
watch: { // 监听 $route 变化调用分享链接 "$route"(to, from) { let currentRouter = this.$router.currentRoute.fullPath; if(currentRouter.indexOf('userShare') == -1){ //如果不是userShare分享页面,则分享另外一个接口 this.shareOut(); }else{ this.shareOutTwo(); //当前页面是userShare页面时分享调用另外一个接口 } } },
4, shareOut() function# in the vue root component
##
let signStr = ''; //sha1加密字符串 let timestamp = 1473254558; //时间戳 let nonceStr = 'shupao'; var obj = { title:"", //标题 desc:"文字描述", //描述 link:"http://www.XXXXXX.com/wx/pub/sr/simpleRegister.do", imgUrl:"http://XXXXXXXXX.com/picactive.jpg" }; this.$ydkAjax({ SENTYPE: "GET", url: this.$domain + '/wx/pub/common/getJsApiTicket.json', //自己服务器获取jsapi_ticket接口 params: null, successFc: (response) => { //拼接sha1加密字符串 signStr = 'jsapi_ticket=' + response.data.data + '&noncestr=' + nonceStr + '×tamp=' + timestamp + '&url=' + window.location.href; var signature = SHA1(signStr); wx.config({ debug: false, appId: "wx6957b3a945a05e90", //appId timestamp: timestamp, //时间戳 nonceStr: nonceStr, //加密需要字符串(自己定义的) signature: signature, //sha1加密后字符串 jsApiList: [ 'onMenuShareTimeline', 'onMenuShareAppMessage'] }); wx.ready(function () { //分享到朋友圈" wx.onMenuShareTimeline({ title: obj.title, link: obj.link, // 分享链接 imgUrl: obj.imgUrl, // 分享图标 success: function () { // console.log('分享到朋友圈成功') }, cancel: function () { // console.log('分享到朋友圈失败') } }); //分享给朋友 wx.onMenuShareAppMessage({ title: obj.title, // 分享标题 desc: obj.desc, // 分享描述 link: obj.link, // 分享链接 imgUrl: obj.imgUrl, // 分享图标 success: function () { // console.log('分享到朋友成功') }, cancel: function () { // console.log('分享到朋友失败') } }); }) }, isLayer: false })
//拼接sha1加密字符串 signStr = 'jsapi_ticket=' + response.data.data + '&noncestr=' + nonceStr + '×tamp=' + timestamp + '&url=' + window.location.href
What are the commonly used instructions in Vue.js
Vue.js custom instruction method
The above is the detailed content of Vue implements the method of sharing other pages on the current page. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



Quark Netdisk and Baidu Netdisk are very convenient storage tools. Many users are asking whether these two softwares are interoperable? How to share Quark Netdisk to Baidu Netdisk? Let this site introduce to users in detail how to save Quark network disk files to Baidu network disk. How to save files from Quark Network Disk to Baidu Network Disk Method 1. If you want to know how to transfer files from Quark Network Disk to Baidu Network Disk, first download the files that need to be saved on Quark Network Disk, and then open the Baidu Network Disk client. , select the folder where the compressed file is to be saved, and double-click to open the folder. 2. After opening the folder, click "Upload" in the upper left corner of the window. 3. Find the compressed file that needs to be uploaded on your computer and click to select it.

Want to copy a page in Microsoft Word and keep the formatting intact? This is a smart idea because duplicating pages in Word can be a useful time-saving technique when you want to create multiple copies of a specific document layout or format. This guide will walk you through the step-by-step process of copying pages in Word, whether you are creating a template or copying a specific page in a document. These simple instructions are designed to help you easily recreate your page without having to start from scratch. Why copy pages in Microsoft Word? There are several reasons why copying pages in Word is very beneficial: When you have a document with a specific layout or format that you want to copy. Unlike recreating the entire page from scratch

1. First, we enter NetEase Cloud Music, and then click on the software homepage interface to enter the song playback interface. 2. Then in the song playback interface, find the sharing function button in the upper right corner, as shown in the red box in the figure below, click to select the sharing channel; in the sharing channel, click the "Share to" option at the bottom, and then select the first "WeChat Moments" allows you to share content to WeChat Moments.

Recently, Baidu Netdisk Android client has ushered in a new version 8.0.0. This version not only brings many changes, but also adds many practical functions. Among them, the most eye-catching is the enhancement of the folder sharing function. Now, users can easily invite friends to join and share important files in work and life, achieving more convenient collaboration and sharing. So how do you share the files you need to share with your friends? Below, the editor of this site will give you a detailed introduction. I hope it can help you! 1) Open Baidu Cloud APP, first click to select the relevant folder on the homepage, and then click the [...] icon in the upper right corner of the interface; (as shown below) 2) Then click [+] in the "Shared Members" column 】, and finally check all

Standby is a new feature in the iOS 17 update that provides a new and enhanced way to access information when your phone is idle quickly. With StandBy, you can conveniently check the time, view upcoming events, browse your calendar, get weather updates for your location, and more. Once activated, the iPhone will intuitively enter standby mode when set to landscape while charging. This feature is perfect for wireless charging points like your bedside table, or when you're away from your iPhone charging during daily tasks. It allows you to swipe through various widgets displayed in standby to access different sets of information from various applications. However, you may want to modify these widgets or even delete some based on your preferences and the information you need frequently. So let's dive into

Page refresh is very common in our daily network use. When we visit a web page, we sometimes encounter some problems, such as the web page not loading or displaying abnormally, etc. At this time, we usually choose to refresh the page to solve the problem, so how to refresh the page quickly? Let’s discuss the shortcut keys for page refresh. The page refresh shortcut key is a method to quickly refresh the current web page through keyboard operations. In different operating systems and browsers, the shortcut keys for page refresh may be different. Below we use the common W

Do you have the latest activation key for win7 enterprise edition? If you install the official win7 enterprise version, you will be prompted to activate it with the windows7 enterprise product key, otherwise it will not work properly. So the editor will share with you some win7 enterprise version activation passwords, let's take a look. Q3VMJ-TMJ3M-99RF9-CVPJ3-Q7VF3KGMPT-GQ6XF-DM3VM-HW6PR-DX9G8MT39G-9HYXX-J3V3Q-RPXJB-RQ6D79JBBV-7Q7P7-CTDB7-KYBKG-X8HHCP72QK-2Y3B8-YDHDV-29DQB-QKWWM6 JQ

In iOS, Apple allows you to disable individual home screen pages on your iPhone. It's also possible to rearrange the order of home screen pages and delete pages directly instead of just disabling them. Here's how it works. How to Rearrange Home Screen Pages Touch and hold Space on the Home screen to enter jitter mode. Tap the row of dots that represent Home screen pages. In the Home screen grid that appears, touch and drag a page to rearrange it relative to other pages. Others move in response to your dragging. When you're happy with your new arrangement, tap "Done" in the upper right corner of the screen, then tap "Done" again to exit dither mode. How to Disable or Remove Home Screen Pages Touch and hold Space on the Home screen to enter dither mode. Tap to represent home screen
