// ... other code router.beforeEach((to, from, next) => { document.title = to.meta.title // 处理jssdk签名,兼容history模式 if (!store.state.url) { store.commit('setUrl', document.URL) } // ... other code
在需要获取签名的组件中获取并进行配置
// ... other code created () { var sef = this var url = '' // 判断是否是ios微信浏览器 if (window.__wxjs_is_wkwebview === true) { url = this.$store.state.url.split('#')[0] } else { url = window.location.href.split('#')[0] } this.$http.get('/api/jssdk?url=' + url).then(function (res) { sef.lists = res.data.data hmTools.wechact(sef.lists, sef) //js-sdk配置 }) } // ...other code