search
HomeWeChat AppletMini Program DevelopmentWeChat Mini Program Example: Implementation Code of Customized Sharing Function

This article brings you an example of WeChat applet: the implementation code of the custom sharing function, which has certain reference value. Friends in need can refer to it. I hope it will be helpful to you.

This chapter introduces the custom sharing function of the mini program.

You can share any page of the mini program to friends or group chats. Note that it is shared with friends or group chats, not shared with Moments. On the one hand, WeChat is trying traffic distribution methods, but at the same time it is unwilling to open the largest traffic entrance.

Development documentation: https://mp.weixin.qq.com/debug/wxadoc/dev/api/share.html?t=20161221

The implementation steps are very simple

Add a custom sharing code in index/index.js as follows, path: '/page/index?id=123', which implements the sharing function of the index home page

示例代码:
Page({
 
  onShareAppMessage: function () {
 
    return {
 
      title: '自定义分享标题',
 
      desc: '自定义分享描述',
 
      path: '/page/index?id=123'
 
    }
 
  }
 
})

Explain the meaning:

Add the following code to Page() and add it to the upper right corner.
title: Shared title.
desc: Share a description.
path: This parameter used to be shared in WeChat and was usually a URL. Here pages/index?id=123 means setting sharing on the home page.

Principle:

Define the onShareAppMessage function in Page and set the forwarding of the page information.

1: Only if this event handler is defined, the "Forward" button will be displayed in the upper right corner menu:
2: When the user clicks the forward button, it will be called:
3: This event requires return An Object, used to customize forwarding content

Related recommendations:

WeChat Mini Program - Custom Creation

WeChat New function of customizing pictures when sharing mini programs

Functional implementation of user-defined templates for WeChat mini programs

The above is the detailed content of WeChat Mini Program Example: Implementation Code of Customized Sharing Function. For more information, please follow other related articles on the PHP Chinese website!

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

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

Hot Article

Hot Tools

SublimeText3 English version

SublimeText3 English version

Recommended: Win version, supports code prompts!

EditPlus Chinese cracked version

EditPlus Chinese cracked version

Small size, syntax highlighting, does not support code prompt function

ZendStudio 13.5.1 Mac

ZendStudio 13.5.1 Mac

Powerful PHP integrated development environment

Safe Exam Browser

Safe Exam Browser

Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.

VSCode Windows 64-bit Download

VSCode Windows 64-bit Download

A free and powerful IDE editor launched by Microsoft