Skip to content

管理微信全局默认分享与局部页面自定义分享,基于typescript+rollup

License

Notifications You must be signed in to change notification settings

ZhaZhengRefn/wechat-share-manager

Folders and files

NameName
Last commit message
Last commit date

Latest commit

2cc6195 · Oct 30, 2018

History

53 Commits
Oct 30, 2018
Oct 30, 2018
Oct 29, 2018
Oct 30, 2018
Sep 25, 2018
Oct 29, 2018
Sep 25, 2018
Sep 25, 2018
Oct 30, 2018
Oct 30, 2018
Oct 30, 2018
Oct 30, 2018
Oct 30, 2018

Repository files navigation

wechat-share-manager

管理微信全局默认分享与局部页面自定义分享

用法

依赖

这个插件依赖于:

  1. 首先您需要保证已经初始化js-sdk。即步骤三,通过config接口注入权限认证
  2. 使用Vue与Vue Router

语法

yarn add wechat-share-manager
// 初始化js-sdk后,在入口文件处初始化默认分享
import Vue from 'vue'
import VueRouter from 'vue-router'
// 引入weixin-js-sdk或者通过script标签全局引入
import wx from 'weixin-js-sdk'
// ...初始化router
const router = new VueRouter([{
  name: 'index',
  path: '/index',
}])
import Share from 'wechat-share-manager'
const share = new Share(Vue, router, wx)
share.init({
  title: 'foo',
  desc: 'bar',
  imgUrl: 'http://via.placeholder.com/350x350',
  link: 'https://github.com/ZhaZhengRefn/wechat-share-manager',
})
// 单个路由页面的自定义分享
// 例如,可以在某个钩子函数中初始化。本插件会保证自定义分享会在默认分享初始化后再初始化。
// ...
mounted() {
  this.$initShare({
    title: 'custom-foo',
    desc: 'custom-bar',
    imgUrl: 'http://via.placeholder.com/350x350',
    link: 'https://github.com/ZhaZhengRefn/wechat-share-manager',  
  })
}
// ...
// 也可以传入回调函数,自定义分享流程
mounted() {
  this.$initShare(() => {
    wx.ready(() => {
      wx.onMenuShareTimeline(timeLineShareConfigObj);
      wx.onMenuShareAppMessage(AppMessageShareConfigObj);
    });    
  })  
}

About

管理微信全局默认分享与局部页面自定义分享,基于typescript+rollup

Resources

License

Stars

Watchers

Forks

Packages

No packages published