最近在写表单中用到了field

field.getValue('spuVideoFlag') === '1' ? <UpLoadVideo /> :
(field.getValue('spuVideoFlag') === '2' ? <ThirdVideo />
: '')
 
 
其中<ThirdVideo />中  return() 这段代码,点击input输入时,输一个就会失去光标
 
       <FormItem
                label="第三方视频链接:"

            >
            <Input placeholder="请输入第三方视频链接通用代码" {...init('videoUrl', {
                  initValue: '',
                  rules: [{
                      required: true
                  }]
                })} />

            </FormItem>

 

 

网上查了类似的问题,大佬们这样回答
react 踩坑之input框输一个字会自动失去光标

 

 

 

实验了一下,把刚才的<ThirdVideo />直接替换成里面的代码,问题就解决了

{
           field.getValue('spuVideoFlag') === '1' ? <UpLoadVideo /> :
           (field.getValue('spuVideoFlag') === '2' ? <FormItem
                label="第三方视频链接:"

            >
            <Input placeholder="请输入第三方视频链接通用代码" {...init('videoUrl', {
                  initValue: '',
                  rules: [{
                      required: true
                  }]
                })} />

            </FormItem>
              : '')
         }

 

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-04-20
  • 2021-05-19
  • 2022-12-23
  • 2021-12-18
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-04-21
  • 2022-12-23
  • 2022-12-23
  • 2021-05-13
  • 2022-01-09
相关资源
相似解决方案