美文网首页
微信小程序转发功能

微信小程序转发功能

作者: 最帅的坏兔子 | 来源:发表于2018-11-18 23:36 被阅读13次

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

相关文章

网友评论

      本文标题:微信小程序转发功能

      本文链接:https://www.haomeiwen.com/subject/wamnfqtx.html