Click on the WeChat applet icon to realize the sharing function

1. How to implement the mini program sharing function.
There are two ways to implement the mini program sharing function. Monitor the behavior of users clicking the forward button (component open-type="share") or the "forward" button in the upper right corner menu on the page, and customize the forwarded content. .
To use the sharing function of the WeChat applet, you need to define the onShareAppMessage(Object object) function. Only when this function exists can the sharing function be triggered. The
official website introduction is as follows:

2. Define the icon button that triggers the sharing function
. Note that setting open-type="share" is used to trigger the sharing function.

<button class="iconfont icon-yaoqing" style="font-size:65rpx;width:100%" open-type="share"></button>
1
效果查看
Insert image description here

You can see that the icon is displayed on the button, but it has its own style, which is a bit ugly and needs to be removed.
My button exists under student-orther-icon. Clear the button style under this class. 

/*Button comes with style clear*/
.student-orther-icon button::after {   border: none !important;   padding: 0 !important;   margin: 0 !important; }



.student-orther-icon button {
  background-color: transparent !important;
  padding: 0 !important;
  line-height: inherit !important;
  margin: 0 !important;
  width: auto !important;
  font-weight: 500 !important;
  border-radius: none !important;
}
 

  //Share function
  onShareAppMessage(res){     //Determine whether the trigger method is a button     if(res.from=="button"){       //Parameter       let uid = "111";       return{         title:"title",         path: "/pages/dynamic/dynamic?uid="+uid       }     }   }










 

Insert image description here

In this way, the sharing function is simply implemented 

Guess you like

Origin blog.csdn.net/Achong999/article/details/130709923