龙空技术网

ElementUI:文本框实现远程搜索的用法

数据库技术分享社区 655

前言:

如今姐妹们对“搜索框html代码”大约比较重视,姐妹们都想要了解一些“搜索框html代码”的相关资讯。那么小编同时在网摘上收集了一些有关“搜索框html代码””的相关知识,希望小伙伴们能喜欢,大家快快来了解一下吧!

今天继续给大家分享一下Element UI 多选框组用法笔记,直接上代码!

1、HTML

<el-form-item label="用户列表">    <el-autocomplete            class="inline-input"            @clear="clearUser"            clearable            v-model="paramData.userName"            :fetch-suggestions="querySearch"            placeholder="请输入用户名"            @select="handleSelect"    >    </el-autocomplete></el-form-item>
2、JS

var vue = new Vue({    data: {        paramData: {            userId: "",            userName: ""        },        userList: []    },    created: function() {        var self = this;        self.initUser("");    },    mounted: function() {},    methods: {},    methods: {        initUser: function(userName) {            var self = this;            var queryParam = {};            $.ajax({                url: xxx,                contentType: 'application/json',                data: JSON.stringify(queryParam),                success: function(resultData) {                    if (resultData.success) {                        self.userList = result.data;                    } else {                        self.userList = [];                    }                }            });        },        handleSelect: function(item) {            var self = this;            self.paramData.userName = item.value;            self.paramData.userId = item.id;            self.onSearch();        },        querySearch: function(queryString, cb) {            var self = this;            var queryParam = {};            $.ajax({                url: xxx,                contentType: 'application/json',                data: JSON.stringify(queryParam),                success: function(resultData) {                    if (resultData.success) {                        cb(result.data);                    } else {                        cb([]);                    }                }            });        },        clearUser: function() {            var self = this;            self.paramData.userName = "";            self.paramData.userId = "";            //重新加载数据列表        }    }});

以上是分享内容,感谢阅读,欢迎收藏、点赞、转发。您的支持是我最大的创作动力,有问题可以留言大家共同进步!

标签: #搜索框html代码