收藏
回答

history.replaceState 影响微信浏览器长按识别二维码

信息:iphone8plus, iphone x max, 微信7.0.15


<html>


<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>replaceState影响识别二维码title>
  <style>
    button {
      width100%;
      height4em;
    }
  style>
head>


<body>
  <div>history.replaceState 之后长按无 识别二维码div>
  <img src="https://res.wx.qq.com/a/wx_fed/weixin_portal/res/static/img/2cPoBPC.png">
  <button onclick="hack()">点击该按钮修复button>
  <script>
    // 这行代码会影响长按二维码识别
    history.replaceState('''', location.href.replace(/\?(.*)|$/'?q=' + Math.random()))


    // 本人发现的修复方式
    function hack() {
      location.replace(location.href.replace(/#(.*)|$/'#$1'))
    }
  script>
body>


html>



...

最后一次编辑于  2020-09-04
回答关注问题邀请回答
收藏

1 个回答

  • 疯狂的小辣椒
    疯狂的小辣椒
    2020-09-03

    请具体描述问题出现的流程,并提供能复现问题的简单代码片段https://developers.weixin.qq.com/miniprogram/dev/devtools/minicode.html

    2020-09-03
    有用
    回复 5
    • 💧
      💧
      2020-09-04
      是微信浏览器,不是小程序。代码就几行,我已经更新在上面。
      2020-09-04
      回复
    • 💧
      💧
      2020-09-04
      再随便提一个bug,上面的代码被吃掉了一些字符 `
      2020-09-04
      回复
    • 💧
      💧
      2020-09-04
      /
      2020-09-04
      回复
    • 💧
      💧
      2020-09-04
      <
      2020-09-04
      回复
    • 疯狂的小辣椒
      疯狂的小辣椒
      2020-09-04回复💧
      给下复现的链接
      2020-09-04
      回复
登录 后发表内容
问题标签