zoukankan      html  css  js  c++  java
  • 解决iOS跳转页面被浏览器缓存不会自动刷新页面问题

    微信服务号开发时今日支付页面支付时iOS会出现当前链接还是上一个页面的链接导致微信支付失败,提示当前页面的url未注册,解决方案是判断如果是iOS的话进入该页面就自动刷新一遍。

    路由文件index.js里:

    router.beforeEach((to, from, next) => {
      // ...
      if (from.name != null || to.name != "toPay"){
        let u = navigator.userAgent;
        let isAndroid = u.indexOf('Android') > -1 || u.indexOf('Adr') > -1; //android终端
        let isiOS = !!u.match(/(i[^;]+;( U;)? CPU.+Mac OS X/); //ios终端
        localStorage.setItem("isiOS", true)
    
      }
      if (to.query.ticket){
        api.userIsLogin().then(res => {
    
          localStorage.setItem("userIsLogin", res)
          if (res == false) {
            api.getUsername(to.query.ticket).then(res => {
              console.log('getUsername', res)
              api.getMyInfo().then(res => {
                // alert("获取我的信息"+JSON.stringify(res))
                console.log("获取我的信息", res)
                next()
    
              })
            })
          } else {
            next()
          }
        })
    
      }else{
        console.log(to, from, location.href, querystring.parse())
        next()
      }
    })

    支付页里:

    mounted () {
    
        if(location.search){
          location.href = location.href.replace(location.search,"")
        }else{
          if(localStorage.getItem("isiOS") == "true"){
            localStorage.removeItem("isiOS")
            window.location.reload();
          }
        }
    
    
      },
  • 相关阅读:
    中间件
    Linux命令
    Ionic 2 Guide
    JSON WEB TOKENS
    用MSBuild和Jenkins搭建持续集成环境(2)
    用MSBuild和Jenkins搭建持续集成环境(1)
    全文检索和消息队列
    redis之如何配置jedisPool参数
    Redis Clients Handling
    redis.clients.jedis.exceptions.JedisConnectionException: Could not get a resource from the pool
  • 原文地址:https://www.cnblogs.com/jongsuk0214/p/9364900.html
Copyright © 2011-2022 走看看