简体   繁体   中英

reactJs on IE9 throwing errors

I managed to create a login form using reactJs : https://jsbin.com/qehifu/1

I get this error on IE9 (works fine on Chrome):

SCRIPT5007 : Unable to get the property value "remove": null object or undefined

SCRIPT5007 : Unable to get the property value "add": null object or undefined

    isValid: function (input) {
    //check required field
    if (input.getAttribute('required') != null && input.value ==="") {
        input.classList.add('error'); //add class error
        input.nextSibling.textContent = this.props.messageEmail; // show error message
        return false;
    }
    else {
        input.classList.remove('error');
        input.nextSibling.textContent = "";

        //rest of the file...

    }

can you guys help ? thanks

The ClassList API was only introduced to IE in V10.

You could think about using a polyfill, like the one here > https://github.com/eligrey/classList.js/

Source: https://developer.mozilla.org/en-US/docs/Web/API/Element/classList#Browser_compatibility

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM