Stripe.js 抱怨被收录两次
Stripe.js complaining about being included twice
我正在尝试使用 Stripe.js,但我在控制台中收到以下警告:
It looks like Stripe.js was loaded more than one time. Please only load it once per page.
javascript只出现在页面上一次,开发者工具的网络选项卡确认脚本只下载了一次,但我仍然出现上述错误,Stripe
对象未定义。有人有什么想法吗?
是我的错误。条带脚本只有 运行 一次,但我有另一个名为 Stripe
的 javascript 对象,它在 stripe.js 脚本加载之前被定义。
请试试这个,对我来说它有效
componentWillMount() {
const stripeExists = document.getElementById('stripev3');
if (!stripeExists) {
const stripeScript = document.createElement('script');
stripeScript.src = 'https://js.stripe.com/v3/';
stripeScript.async = true;
stripeScript.id = 'stripev3';
document.head.appendChild(stripeScript);
}
}
我正在尝试使用 Stripe.js,但我在控制台中收到以下警告:
It looks like Stripe.js was loaded more than one time. Please only load it once per page.
javascript只出现在页面上一次,开发者工具的网络选项卡确认脚本只下载了一次,但我仍然出现上述错误,Stripe
对象未定义。有人有什么想法吗?
是我的错误。条带脚本只有 运行 一次,但我有另一个名为 Stripe
的 javascript 对象,它在 stripe.js 脚本加载之前被定义。
请试试这个,对我来说它有效
componentWillMount() {
const stripeExists = document.getElementById('stripev3');
if (!stripeExists) {
const stripeScript = document.createElement('script');
stripeScript.src = 'https://js.stripe.com/v3/';
stripeScript.async = true;
stripeScript.id = 'stripev3';
document.head.appendChild(stripeScript);
}
}