微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

我想在我的项目中自定义条纹形式作为反应

如何解决我想在我的项目中自定义条纹形式作为反应

我想在react js中使用stripe创建一个支付表单,后端在spring boot中我正在使用formik来获取表单数据和表单验证是的,因为我是react的新手我需要帮助定制stripe表单 现在我正在做这样的事情

                     <Formik
                            enableReinitialize={true}
                            initialValues={RecurringPaymentSchema}
                            validationSchema={RecurringPaymentValidationSchema}
                            onSubmit={({ setSubmitting,resetForm,setErrors }) => {
                              this.handleSubmit(resetForm,setErrors);
                              setSubmitting(false);
                              //resetForm();
                            }}
                          >
                            <Form>
                              <div className="py-2">
                                <div className="custom-control custom-radio">
                                  <Field
                                    className="custom-control-input"
                                    name="monthly-plan"
                                    type="radio"
                                    value="monthly-subscription"
                                  />
                                  <label className="custom-control-label" for="monthly-plan">
                                    <strong>Monthly $9.99</strong>
                                    <br />
                                    <small className="text-muted">
                                      Pay $9.99 every month and get access to all premium features.
                                    </small>
                                  </label>
                                </div>
                                <div className="custom-control custom-radio mt-3">
                                  <Field
                                    checked=""
                                    className="custom-control-input"
                                    name="annually-plan"
                                    type="radio"
                                    value="annual-subscription"
                                  />
                                  <label className="custom-control-label" for="annually-plan">
                                    <strong>Yearly $49.99</strong>
                                    <span className="badge badge-primary ml-1">60% OFF</span>
                                    <br />
                                    <small className="text-muted">
                                      Pay $49.99 every year and get access to all premium features.
                                    </small>
                                  </label>
                                </div>
                              </div>
                              <input id="api-key" type="hidden" value="${stripePublicKey}" />
                              <div className="form-group">
                                <label className="font-weight-medium" for="card-element">
                                  Enter credit or debit card below
                                </label>
                                <div className="w-100">
                                  {/* A Stripe Element will be inserted here. */}
                                  <Elements stripe={stripePromise}>
                                    <CardElement
                                      id="card-element"
                                      options={CARD_ELEMENT_OPTIONS}
                                      onChange={this.handleError}
                                    />
                                  </Elements>
                                </div>
                              </div>
                              <div className="form-group">
                                <Field
                                  className="form-control"
                                  id="email"
                                  name="email"
                                  placeholder="Email Address"
                                  type="email"
                                />
                                <p className="errors">
                                  <ErrorMessage name="email" />
                                </p>
                              </div>
                              {/* Used to display Element errors. */}
                              <div
                                className="text-danger w-100"
                                id="card-errors"
                                role="alert"
                              ></div>
                              <div className="form-group pt-2">
                                <button
                                  className="btn btn-primary btn-block"
                                  id="submitButton"
                                  type="submit"
                                >
                                  Pay With Your Card
                                </button>
                              </div>
                            </Form>
                          </Formik>

enter image description here

现在我想使用 yup 验证条带以及我的单选按钮或其他表单元素 我的架构是

import * as Yup from 'yup';

export const RecurringPaymentSchema = {
  monthlyPlan: '',annuallyPlan: '',email: '',};

export const RecurringPaymentValidationSchema = Yup.object().shape({
  email: Yup.string().required("Email can't be blank"),});

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐


Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其他元素将获得点击?
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。)
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbcDriver发生异常。为什么?
这是用Java进行XML解析的最佳库。
Java的PriorityQueue的内置迭代器不会以任何特定顺序遍历数据结构。为什么?
如何在Java中聆听按键时移动图像。
Java“Program to an interface”。这是什么意思?