Yii2 尝试将Kartik Select2与ajax一起使用时出错

Yii2 尝试将Kartik Select2与ajax一起使用时出错,yii2,yii2-advanced-app,kartik-v,Yii2,Yii2 Advanced App,Kartik V,我以前在ajax中使用过很多次kartiks select2。现在,当我再次尝试实现它时,控制台中会抛出此错误: jquery.js:3850 Uncaught Error: Option 'ajax' is not allowed for Select2 when attached to a <select> element. 此错误以前出现在旧的select2 v3上,而kartik使用的是v4,您能否再次检查加载的js文件中的select2.js,或者控制台上是否存在除上述错

我以前在ajax中使用过很多次kartiks select2。现在,当我再次尝试实现它时,控制台中会抛出此错误:

jquery.js:3850 Uncaught Error: Option 'ajax' is not allowed for Select2 when attached to a <select> element.

此错误以前出现在旧的select2 v3上,而kartik使用的是v4,您能否再次检查加载的js文件中的
select2.js
,或者控制台上是否存在除上述错误以外的任何错误?还可以从项目中添加
composer.json
,无其他错误。已从composer.json中添加了我的select2部分
<?php
                echo $form->field($model, 'destination_from')->widget(Select2::class, [
                    'initValueText' => isset($_GET['MassManagementSearch']) ? $_GET['MassManagementSearch']['destination_from'] : [], // set the initial display text
                    'options' => [
                        'placeholder' => 'Destination from ...',
                        'multiple' => true
                    ],
                    'pluginOptions' => [
                        'allowClear' => true,
                        'minimumInputLength' => 3,
                        'language' => [
                            'errorLoading' => new JsExpression("function () { return 'Waiting for results...'; }"),
                        ],
                        'ajax' => [
                            'url' => \yii\helpers\Url::to(['destination-from']),
                            'dataType' => 'json',
                            'data' => new JsExpression('function(params) { return {q:params.term}; }')
                        ],
                        'escapeMarkup' => new JsExpression('function (markup) { return markup; }'),
                        'templateResult' => new JsExpression('function(city) { return city.text; }'),
                        'templateSelection' => new JsExpression('function (city) { return city.text; }'),
                    ],
                ]); ?>
"kartik-v/yii2-widget-select2": "@dev"