代码之家  ›  专栏  ›  技术社区  ›  flash

未捕获的TypeError:reportValidity[]不是函数

  •  0
  • flash  · 技术社区  · 6 年前

    Uncaught TypeError: e.reportValidity[s] is not a function
        at HTMLButtonElement.<anonymous> 
        at f  (Line#57)
        at HTMLDivElement.f.handle
        at HTMLDivElement.dispatch 
    


    const legalityMethod = function () { 
    return 'reportValidity' in document.createElement('input') ? 'reportValidity' : 'checkValidity'; 
    }();
    

    第57行对应以下while循环;

    function validate(form, field) {
    
        while (m && m--) {
    
            switch (fields[m]) {
    
                case 'hello_world':
    
                    form.hello_world.setCustomValidity(config.language['amazing_world']);
                    break;
            }
        }
    
        return form.reportValidity[legalityMethod]();  //line#57
    }
    

    问题陈述:

    我想知道这个错误背后的原因是什么,我如何才能摆脱这个错误。

    0 回复  |  直到 6 年前