zoukankan      html  css  js  c++  java
  • react 项目微信端 签名失败 原因

    用SPA做微信h5,调用微信jssdk的页面,安卓微信上木有问题,ios微信报当前url未注册
    
    经过调试,是ios微信版本问题导致页面跳转url未变化,导致验签失败
    
    所以我们大致的思想就是:在ios微信环境中(判断浏览器环境请参考我的另一篇文章–js判断浏览器环境),如果跳转页面与当前页面的url不一致,那么就重载刷新整个跳转页面
    
    因为项目使用vue,所以我们使用vue-router的钩子函数beforeRouterEnter()来做此操作
    
    将钩子函数写入js模块,使用时候混入页面vue实例选项即可
    
    // mixins/assign.js
    import { isIOSWeChat } from '../utils'
    
    const location = global.location
    
    export default {
      beforeRouteEnter(to, from, next) {
        // XXX: 修复iOS版微信HTML5 History兼容性问题
        if (isIOSWeChat() && to.path !== location.pathname) {
          // 此处不可使用location.replace
          location.assign(to.fullPath)
        } else {
          next()
        }
      },
    }
    然后在vue文件中
    
    import assign from 'mixins/assign.js'
    
    export default {
        ···
        mixins: [assign],
        ···
    }
    

      

    react 项目微信端 签名失败  分享url 报错
    原因是:微信jsdk校验签名时拿取的本地url 为上一个页面。(可以用原生跳转)
  • 相关阅读:
    Codefores 506A Mr. Kitayuta, the Treasure Hunter( DP && dfs )
    Goals ? Ideals ?
    HDU 5159 Card( 计数 期望 )
    HDU 1387 Team Queue( 单向链表 )
    HDU 1709 The Balance( DP )
    HDU 2152 Fruit( DP )
    HDU 1398 Square Coins(DP)
    HDU 5155 Harry And Magic Box( DP )
    HDU 3571 N-dimensional Sphere( 高斯消元+ 同余 )
    最大连续自序列
  • 原文地址:https://www.cnblogs.com/winyh/p/8043641.html
Copyright © 2011-2022 走看看