使用Malihu滚动插件时遇jQuery错误:Unsupported pseudo: mcsInView
Hey there, let's work through this frustrating error you're seeing with the Malihu Custom Scrollbar plugin and jQuery 3.3.1. I've dealt with similar selector-related issues in jQuery plugins before, so here are the most likely fixes to check:
Double-check your script load order
This is the #1 culprit for this kind of error. Malihu's custom pseudo selectors like:mcsInVieware registered on top of jQuery, so jQuery needs to be loaded first, followed by the Malihu plugin. If you load Malihu before jQuery, the plugin can't register the selector, and jQuery will throw that "unsupported pseudo" error when you try to use it. Make your script tags look like this:<!-- Load jQuery FIRST --> <script src="jquery-3.3.1.min.js"></script> <!-- Then load Malihu's script --> <script src="jquery.mCustomScrollbar.concat.min.js"></script>The demo page almost certainly follows this order, which is why it works there but not in your project.
Verify plugin and jQuery version compatibility
While jQuery 3.3.1 is fairly stable, older versions of the Malihu plugin might not fully support jQuery 3.x's selector API changes. Check the plugin's documentation to confirm it's compatible with your jQuery version, or try updating to the latest stable release of Malihu Custom Scrollbar. Often, updating resolves these subtle compatibility gaps.Check for typos in the pseudo selector
jQuery's pseudo selectors are case-sensitive! If you accidentally wrote:mcsInview(lowercase "v") instead of the correct:mcsInView(uppercase "V"), jQuery won't recognize it and throw that error. Double-check every instance where you use the selector to make sure the casing matches exactly what the plugin specifies.Rule out plugin conflicts
Other jQuery plugins might overwrite or interfere with jQuery's pseudo selector registration system. To test this, temporarily remove all other jQuery plugins from your project, leaving only jQuery and Malihu. If the error goes away, you've found a conflict. Re-add the plugins one by one to identify which one is causing the issue, then adjust load order or look for configuration options in the conflicting plugin to avoid the overlap.Validate the selector is registered
Open your browser's developer console and run this command:console.log($.expr.pseudos.mcsInView);If it returns
undefined, the plugin didn't successfully register the selector (go back to checking load order and version compatibility). If it returns a function, the selector is registered correctly, and the issue is likely in how you're using it or a conflict elsewhere.
内容的提问来源于stack exchange,提问作者Artyom Sosonko

