是的 React 中的导入问题
Yup Import Problems in React
有人可以帮助我吗,我正在通过以下方式使用 Yup 的 React-Bootstrap 验证示例(它是 this page if you scroll down to Validation):
const schema = yup.object().shape({
firstName: yup.string().required(),
lastName: yup.string().required(),
username: yup.string().required(),
city: yup.string().required(),
state: yup.string().required(),
zip: yup.string().required(),
terms: yup.bool().required().oneOf([true], 'Terms must be accepted'),
});
它没有显示 Yup 是如何导入的。但是我在我的 JS 文件中按如下方式正确导入它:
import * as Yup from 'yup';
和以下来自不同示例的不同版本,例如大写Yup.string()..
适合我:
validationSchema={Yup.object({
firstName: Yup.string()
.max(15, 'Must be 15 characters or less')
.required('Required'),
lastName: Yup.string()
.max(20, 'Must be 20 characters or less')
.required('Required'),
email: Yup.string().email('Invalid email address').required('Required'),
})}
当我尝试使 Bootstrap-React 教程与其小写版本一起工作时,
Line 7:16: 'yup' is not defined no-undef
Line 8:14: 'yup' is not defined no-undef
Line 9:13: 'yup' is not defined no-undef
Line 10:13: 'yup' is not defined no-undef
有什么想法吗?
import * as yup from 'yup'
呢?
有人可以帮助我吗,我正在通过以下方式使用 Yup 的 React-Bootstrap 验证示例(它是 this page if you scroll down to Validation):
const schema = yup.object().shape({
firstName: yup.string().required(),
lastName: yup.string().required(),
username: yup.string().required(),
city: yup.string().required(),
state: yup.string().required(),
zip: yup.string().required(),
terms: yup.bool().required().oneOf([true], 'Terms must be accepted'),
});
它没有显示 Yup 是如何导入的。但是我在我的 JS 文件中按如下方式正确导入它:
import * as Yup from 'yup';
和以下来自不同示例的不同版本,例如大写Yup.string()..
适合我:
validationSchema={Yup.object({
firstName: Yup.string()
.max(15, 'Must be 15 characters or less')
.required('Required'),
lastName: Yup.string()
.max(20, 'Must be 20 characters or less')
.required('Required'),
email: Yup.string().email('Invalid email address').required('Required'),
})}
当我尝试使 Bootstrap-React 教程与其小写版本一起工作时,
Line 7:16: 'yup' is not defined no-undef
Line 8:14: 'yup' is not defined no-undef
Line 9:13: 'yup' is not defined no-undef
Line 10:13: 'yup' is not defined no-undef
有什么想法吗?
import * as yup from 'yup'
呢?