Why do the above error reports occur
If you see the error “typeerror: replaceall is not a function”, it may be that your browser version or node.js version does not support this method.
we should note that: string. Prototype. Replaceall()
The method is added in ES2021/ES12, which is probably not supported by the environment.
How to solve it?
You can use “string. Prototype. Replace()” as a substitute for “string. Prototype. Replaceall()”, replace()
Just set a global (g) in the replaced regular expression. This processing method is the same as that of replaceall(). Here is an example of comparison:
const str = 'foo-bar'; // in older browsers const result1 = str.replace(/foo/g, 'moo'); // ES12+ const result2 = str.replaceAll('foo', 'moo'); // output: 'moo-bar' console.log(result1); console.log(result2);
Similar Posts:
- [Solved] Vue route Duplicate Error: error avoid redundant navigation to current location: “/home”
- How to Use Array.prototype.slice.call(arguments)
- URL transcoding (including Chinese): 3A to ‘:’,% 2F to ‘/’
- Solution to the problem of “TypeError: Assignment to constant variable”
- Uncaught (in promise) NavigationDuplicated [How to Solve]
- [Solved] Uncaught (in promise) NavigationDuplicated: Avoided redundant navigation to current location
- [Solved] Vue Error: Uncaught (in promise) NavigationDuplicated: Avoided redundant navigation to current location
- core-js & RegExp error All In One [How to Solve]
- [Solved] Vue router in the element UI navigation bar repeatedly clicks on the menu above version 3.0 and reports errors
- C# String was not recognized as a valid DateTime [How to Solve]