初始化Stripe变量后如何更改Stripe语言环境

时间:2020-04-24 11:19:18

标签: typescript stripe-payments

我在TypeScript应用程序中使用stripe,并且我读到可以用以下语言环境设置stripe变量:var stripe = Stripe('pk_test', {locale: 'en'});,但是如果我想在之后更改语言初始化我无法做到... 我以为创建stripe变量的新实例,但库中显示:IntegrationError: Please use the same instance of 'Stripe' you used to create this Element to create your Source or Token.

那么我需要在运行时更改语言环境吗?

谢谢!

1 个答案:

答案 0 :(得分:3)

我认为可以使用新的语言环境[0]重新初始化elements对象。然后,根据您的新Elements对象重新安装元素,此测试似乎可以将西班牙设置更改为德语设置[1]。

elements = stripe.elements( {locale: 'de'});

希望有帮助!

[0] https://stripe.com/docs/js/elements_object/create#stripe_elements-options-locale

[1] https://jsfiddle.net/v3nkm4n/5uz6mrbh/20/