【问题标题】:Jquery Qrcode Function not working when put inside timeoutJquery Qrcode功能在超时时不起作用
【发布时间】:2023-03-24 12:55:01
【问题描述】:

请帮帮我,我在实现 Jquery QRCODE 时感到困惑,我想创建一个带有 boostrap 4 的模态,显示 qrcode 图像 当我实现这样的代码时,二维码是图像显示

<script>
$('#qrcode').qrcode('123');
</script>

但是当我将 qrcode 函数放入 timeout 时,我得到了这样的错误

未捕获的类型错误:$(...).qrcode 不是函数

(我想从 api 获取 qrcode 值的值)所以我尝试用 timeout 模拟它,这里是不显示图像的超时函数..

<script>
setTimeout(function () {
    $('#qrcode').qrcode('123');        
}, 5000);

</script>

之前...

【问题讨论】:

    标签: jquery bootstrap-4 modal-dialog qr-code laravel-blade


    【解决方案1】:

    它可能包括图书馆问题的顺序。 qrcode 方法在调用 settimeout 函数时可能未绑定。

    在 JQuery 中使用 delayqueue 方法。

    $('#qrcode').delay(5000).queue(function() {
      $(this).qrcode('123');
    })
    
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-05-06
      • 1970-01-01
      • 1970-01-01
      • 2016-08-09
      • 2021-03-27
      • 2011-12-03
      • 2019-04-08
      • 2012-11-29
      相关资源
      最近更新 更多