How can I using select2 with webpack?

前端 未结 5 1281
醉酒成梦
醉酒成梦 2020-12-14 06:55

I\'m using webpack to manage all my assets, when I use this code to require select2 (https://github.com/select2/select2) I got the error

$(...).selec

5条回答
  •  夕颜
    夕颜 (楼主)
    2020-12-14 07:16

    You can run select2 in this way:

    import $ from 'jquery';
    import 'select2';                       // globally assign select2 fn to $ element
    import 'select2/dist/css/select2.css';  // optional if you have css loader
    
    $(() => {
      $('.select2-enable').select2();
    });
    

提交回复
热议问题