尝试实现stripe.js元素,您必须做的一件事情是"mount" the card。
// Custom styling can be passed to options when creating an Element.
var style = {
base: {
// Add your base input styles here. For example:
fontSize: '16px',
color: "#32325d",
}
};
// Create an instance of the card Element.
var card = elements.create('card', {style: style});
// Add an instance of the card Element into the `card-element` <div>.
card.mount('#card-element');
但是随后我们有一些针对此“卡”的代码,并且取决于连接速度或某些错误,我们会出错。
我们需要“等待”卡的实际安装,在React中他们实际上可以使用Stripe React方法__isMounted(请参见here或here),但找不到对应的或任何“等待”卡的方式都是使用香草javascript。