相当于React的_isMounted的Stripe / js(Elements)用于普通javascript

时间:2018-12-02 21:23:34

标签: javascript stripe-payments

尝试实现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(请参见herehere),但找不到对应的或任何“等待”卡的方式都是使用香草javascript。

0 个答案:

没有答案