Select2 4.0 占位符未定义

Select2 4.0 placeholder undefined

拜托,帮忙。

html:

<select id="select-client" class="form-control" style="width: 350px;"></select>

js:

$("#select-client").select2({
    ajax: {
        url: _app.url + "finduser",
        dataType: 'json',
        delay: 250,
        data: function (params) {
            return {
                q: params.term
            };
        },
        processResults: function (data) {
            return {
                results: data
            };
        },
        cache: true
    },
    escapeMarkup: function (markup) { return markup; },
    minimumInputLength: 2,
    templateResult: formatClientRepo,
    templateSelection: formatClientRepoSelection,
    placeholder: "Enter user name"
});

结果我收到了这个:http://prntscr.com/76jxvi 我发现了很多变体,比如 select 中的空选项,或者 select 中的占位符,但没有。

https://jsfiddle.net/xqhp0z0x/1/

在此示例中,如果我们从 formatRepoSelection 中删除 || repo.text,它将不起作用。因为 repo.text 是占位符。

P.S。 select2 4.0 不需要为 placeholder working

清空 option 标签