微信小程序转发功能

1.WXML

<view class="container">
  <view><button class='question' open-type='share'>转发</button></view>
</view>

2.WXSS

.question{
  width: 80%;
  height: 50px;
  position: fixed;
  top: 5%;
  left: 10%;
  line-height: 50px;
  color: #fff;
  font-size: 30px;
  background-color: #34e3f3;
  border: 1px solid #eee;
  text-align: center;
}

3.JS

const app = getApp()
Page({
  //转发
  onShareAppMessage: function(res){
    if(res.from === 'button'){
      console.log(res.target)
    }else if(res.from === "menu"){
      console.log(res)
    }
    return {
      title: '转发关注小可爱',
      path: '/pages/logs/logs'
    }
  }
})

4.效果展示


转发按钮效果.png
menu菜单转发.png
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

友情链接更多精彩内容