You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

在Angular 2项目中使用jquery-3.2.1.SLIM.min.js与selectize.js报错的最优解决方案

解决Angular 2中jQuery Slim + Selectize.js的TypeError: self.$dropdown_content.stop is not a function问题

Hey there, let's break down this issue and fix it up properly!

问题根源

The error you're seeing boils down to one key detail: jQuery Slim versions strip out non-core functionality like animation methods—and stop() is exactly one of the methods that gets cut. Selectize.js relies on this method to handle dropdown menu animations, so when it tries to call stop() on a jQuery object from the Slim build, it throws that type error.

最优解决方案

The most reliable and low-fix solution is to replace jQuery Slim with the full jQuery version:

  • If you're using npm to manage dependencies:
    npm uninstall jquery-slim
    npm install jquery@3.2.1 --save
    
  • If you're using CDN links, swap out the Slim script for the full one:
    <!-- Before (Slim version) -->
    <script src="https://code.jquery.com/jquery-3.2.1.slim.min.js"></script>
    <!-- After (Full version) -->
    <script src="https://code.jquery.com/jquery-3.2.1.min.js"></script>
    
  • Double-check your Angular project's angular.json (or .angular-cli.json for older versions) to make sure the configured jQuery path points to the full build, not the Slim one.

备选方案(仅当无法替换完整版时使用)

If project size constraints force you to stick with jQuery Slim, you can manually patch the missing stop() method. Add this code after loading jQuery Slim but before loading Selectize.js:

// Minimal stop() implementation for jQuery Slim to satisfy Selectize.js
jQuery.fn.stop = function(clearQueue, jumpToEnd) {
  return this.each(function() {
    if (this.nodeType === 1 && this.style) {
      clearTimeout(this._timer);
      if (jumpToEnd) {
        $(this).finish();
      }
    }
  });
};

⚠️ Heads up: This is a bare-bones fix that only covers Selectize's basic needs. It might not work for other animation-related features, so replacing with the full jQuery build is still the better long-term choice.

验证修复

After making the change, restart your Angular dev server and test your Selectize dropdowns—you should no longer see that stop is not a function error pop up.

内容的提问来源于stack exchange,提问作者Semir Hodzic

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.27 07:30:32