Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/453.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript Mobx响应自定义DVR规则_Javascript_Reactjs_Mobx React - Fatal编程技术网

Javascript Mobx响应自定义DVR规则

Javascript Mobx响应自定义DVR规则,javascript,reactjs,mobx-react,Javascript,Reactjs,Mobx React,我有以下自定义规则(): 它们的用途如下: ... { name: 'changePassword', label: 'Change your password', fields: [ { name: 'password', label: t('user:New pasword'), rules: 'password',

我有以下自定义规则():

它们的用途如下:

...
    {
        name: 'changePassword',
        label: 'Change your password',
        fields: [
            {
                name: 'password',
                label: t('user:New pasword'),
                rules: 'password',
                value: itemData.passowrd,
                type: 'password'
            },
            {
                name: 'confirmPassword',
                label: t('user:Confirm password'),
                rules: 'confirmPassword',
                value: itemData.confirmPassowrd,
                type: 'password'
            }
        ]
    },
...

我试图在confirmPassword规则中获取密码的值,但它似乎无法完成我正在做的工作。它返回未定义。

如果您使用的是DVR插件,您只需应用以下规则:

或者,您可以这样使用:

{
  name: 'confirmPassword',
  label: t('user:Confirm password'),
  value: itemData.confirmPassowrd,
  type: 'password',
  validators: ({ field, form }) => [
    field.value === form.$('password').value,
    'Passwords do not match.',
  ],
}
{
  name: 'confirmPassword',
  label: t('user:Confirm password'),
  rules: 'same:password',
  value: itemData.confirmPassowrd,
  type: 'password'
}
{
  name: 'confirmPassword',
  label: t('user:Confirm password'),
  value: itemData.confirmPassowrd,
  type: 'password',
  validators: ({ field, form }) => [
    field.value === form.$('password').value,
    'Passwords do not match.',
  ],
}