【问题标题】:Best way to include the stripe.js script in every gatsby page在每个 gatsby 页面中包含 stripe.js 脚本的最佳方式
【发布时间】:2020-06-04 07:04:47
【问题描述】:

gatsby-stripe-plugin 已弃用。它指出,对于如何将条带加载到代码中,stripe.js 现在有自己的解决方案,例如const stripe = await loadStripe(secret);

但 stripe 在其 readme 中声明,您应该将 stripe 脚本添加到每个文件/页面,而不仅仅是在结帐页面,以检查欺诈行为。

最好的方法是什么。我对 gatsby 很陌生,将条带脚本添加到公用文件夹中的 index.html 是否有效?

【问题讨论】:

    标签: javascript reactjs stripe-payments gatsby


    【解决方案1】:

    您现在可以在每个页面中使用npm install @stripe/stripe-js 然后import '@stripe/stripe-js';,然后include it as suggested

    【讨论】:

    • 好的,我不确定这是否是正确的方法,或者是否有更好的解决方案。非常感谢您的回复!
    猜你喜欢
    • 2013-10-15
    • 2020-08-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-02-28
    相关资源
    最近更新 更多