小编Ard*_*neh的帖子

是的,基于父对象模式的条件验证

我正在使用 array().of 方法创建 Yup 验证模式,我需要根据外部模式对象的值在该数组中设置一些验证规则。我如何获得对该值的引用?


const termsSchema = Yup.object().shape({
  termType: Yup.string().when('condition', {
    is: true,
    then: Yup.string()
      .required('Type is required'),
  }),
});

const schema = Yup.object().shape({
  condition: Yup.boolean()
    .required('Error'),
  terms: Yup.array().of(termsSchema),
});
Run Code Online (Sandbox Code Playgroud)

javascript yup formik

5
推荐指数
2
解决办法
5114
查看次数

JS 中模板字符串中的 HTML 元素

我在模板字符串中添加 HTML 元素时遇到问题。我想在我的<li>元素中添加新行,但<br>被解释为字符串。

let movieDescription = document.createTextNode(`${moviesData[i].title} <br> ${moviesData[i].year} <br> ${moviesData[i].genre} <br>${moviesData[i].summary}`);
Run Code Online (Sandbox Code Playgroud)

如何<br>在模板字符串中添加元素?

html javascript ecmascript-6

4
推荐指数
1
解决办法
7419
查看次数

标签 统计

javascript ×2

ecmascript-6 ×1

formik ×1

html ×1

yup ×1