JS组件 select2

1.引用

<script src="{% static "plugin/select2/js/i18n/zh-CN.js" %}"></script>
    <script src="{% static "plugin/select2/js/select2.min.js" %}"></script>

2.初始化

function initSelect2() {
            $(".select2").select2({}).on("select2:select",function (e) {
                location.href = e.params.data.id;
                console.log(e.params.data);
            }).on("select2:unselect",function (e) {
                location.href = e.params.data.id;
            })
        }
原文地址:https://www.cnblogs.com/hude/p/12848914.html