1

这是用于搜索和选择用于抄送的电子邮件地址的输入。没有taggablev-select 的 AJAX 搜索可以完美地工作,但我需要能够“添加”电子邮件,所以我有一个选择“无论如何都发送”。当我进行 AJAX 搜索时taggable设置为true,它将显示上述字符串,但不显示选项。我已经检查并验证了 AJAX 函数正在返回结果,所以不能这样。

这是我的代码的样子:

<v-select placeholder="" 
    label="firstname" 
    v-model="edit_email_cc"
    :taggable=true
    :filterable=false
    :multiple=true
    :options="search_options"
    @search:blur="handleEmailCCBlur()" 
    v-on:search="fetchSearchOptions">

    <template #no-options="{ search }">
        <span v-if="search == ''">Type to search...</span>
        <span v-else>No person found for "{{search}}"</span>
    </template>

    <template #open-indicator="{ attributes }">
        <span v-bind="attributes"></span>
    </template>

    <template #spinner="{ loading }">
        <div v-if="loading" class="vs__spinner"></div>
    </template>

    <template slot="option" slot-scope="option">
        <div class="v-select-options" v-if="option.lastname == undefined">
            Send to email {{ option.firstname }}
        </div>
        <div class="v-select-options" v-else>
            {{ option.firstname }} {{ option.lastname }} <strong>({{ option.email }})</strong>
        </div>
    </template>
    <template slot="selected-option" slot-scope="option">
        <div class="v-select-options selected">{{ option.firstname }} {{ option.lastname != undefined?option.lastname:'' }}</div>
    </template>

</v-select>

和搜索功能(以防万一)

fetchSearchOptions(keyword, loading) {
    this.search(loading, keyword, this, this.base_url);
},

search: debounce((loading, keyword, vm, base_url) => {
    if (keyword === '') {
        vm.search_options = [];
    }
    if (keyword !== '') {
        var search_url = base_url + '/common/search';
        loading(true);

        axios.post(search_url, {keyword : escape(keyword), field : 'email'})                
            .then(response => {
                vm.search_options = response.data;
                console.log(vm.search_options);
                loading(false);
            })
    }
}, 350),

任何帮助将非常感激!谢谢!

Ĵ

4

0 回答 0