0.1.1 • Published 5 years ago

jason-wxhash v0.1.1

Weekly downloads
1
License
MIT
Repository
github
Last release
5 years ago

jason-wxhash

导致使用 hash url 微信分享时,指向错误的问题

思路:

  1. 将带有 hash 的 url 转成查询字符串(wxhash)连同其他查询字符串拼接到当前 url 路径之后
  2. 页面进入时,检查是否含有指定的查询字符串(wxhash)
    1. 若有,则使用 history.replaceState 改变 url
  3. 基于 url 的功能,均使用改变后的 hash url

install

npm i --save jason-wxhash
import wxHash from 'jason-wxhash';

// 获取处理后的 url
// 参数为默认值
let url = wxHash({
  url: location.origin + location.pathname + location.hash,
  qs: ''
});

wx.updateAppMessageShareData({
  title: '分享标题',
  desc: '分享描述',
  // 分享链接,该链接域名或路径必须与当前页面对应的公众号JS安全域名一致
  link: url,
  imgUrl: '分享图标'
})