我在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.
那么我需要在运行时更改语言环境吗?
谢谢!
答案 0 :(得分:3)
我认为可以使用新的语言环境[0]重新初始化elements对象。然后,根据您的新Elements对象重新安装元素,此测试似乎可以将西班牙设置更改为德语设置[1]。
elements = stripe.elements( {locale: 'de'});
希望有帮助!
[0] https://stripe.com/docs/js/elements_object/create#stripe_elements-options-locale