vue 微信 js-sdk分享功能

  • A+
所属分类:Web前端
摘要

第一步:第二步:第三步:

第一步:

npm install weixin-js-sdk -S // (或者直接index.html里面引入js文件 http://res.wx.qq.com/open/js/jweixin-1.6.0.js

官方文档:https://developers.weixin.qq.com/doc/offiaccount/OA_Web_Apps/JS-SDK.html

第二步:

import wx from 'weixin-js-sdk'  // 喜欢的在main.js里面把wx挂载到Vue下面 Vue.prototype.$wx = wx

第三步:

// 找后台获取签名,(拿签名的接口只需要向后台传递当前页面的url就行了,其他参数更具业务自定,如果后台找你要授权验证的code,就让他自己看文档去) this.$store.dispatch('getAutographCode', {vm: this, devType: 'yanshi', url: window.location.href}).then(res => {   if(res && res.data){     this.$wx.config({       debug: false, // 开启调试模式,调用的所有api的返回值会在客户端alert出来,若要查看传入的参数,可以在pc端打开,参数信息会通过log打出,仅在pc端时才会打印。       appId: res.data.appId, // 必填,