html:
<template> <el-autocomplete popper-class="my-autocomplete" custom-item="my-remote" v-model="state" :fetch-suggestions="querySearch" placeholder="默认空" icon="close" :on-icon-click="handleIconClick"> </el-autocomplete> </template>
js:
<script>
import Vue from 'vue'
Vue.component('my-remote', {
functional: true,
render: function(h, ctx) {
var item = ctx.props.item;
let str = h('li', ctx.data, [
h('div', { attrs: { class: 'name' } }, [item.value]),
h('span', { attrs: { class: 'addr' } }, [item.address])
]);
if (item.str) { // 根据参数不同 修改原模版结构
str = h('center', { attrs: { class: 'ems' } }, [item.str])
}
return str
},
props: {
item: { type: Object, required: true }
}
});
export default {
data() {
return {
restaurants: [],
state: '',
timeout: null,
_that: {} // 记录this,用来发起http请求
};
},
methods: {
querySearch(queryString, cb) {
let restaurants = this.restaurants;
if (restaurants.length > 0) { // 如果参数都没变化,则使用缓存数据,避免请求沉积
let results = queryString "object") {
b = a[1];
a = a[0];
}
serier.push({ "value": a, "address": b })
}
} else { // 如果没有请求到数据,则显示暂无数据!
serier.push({ "str": '暂无数据' })
}
return serier;
},
handleIconClick(ev) {
this.state = "";
}
},
mounted() {
this._that = this;
}
}
</script>
css:
<style lang="scss">
.my-autocomplete {
li {
line-height: normal !important;
padding: 7px !important;
.name {
text-overflow: ellipsis;
overflow: hidden;
}
.addr {
font-size: 12px;
color: #b4b4b4;
}
.highlighted .addr {
color: #ddd;
}
}
.ems {
font-size: 12px;
color: #b4b4b4;
}
}
</style>
总结
以上所述是小编给大家介绍的vue Element-ui input 远程搜索与修改建议显示模版的示例代码,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对网站的支持!
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件!
如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
桃源资源网 Design By www.nqtax.com
暂无“vue Element-ui input 远程搜索与修改建议显示模版的示例代码”评论...
P70系列延期,华为新旗舰将在下月发布
3月20日消息,近期博主@数码闲聊站 透露,原定三月份发布的华为新旗舰P70系列延期发布,预计4月份上市。
而博主@定焦数码 爆料,华为的P70系列在定位上已经超过了Mate60,成为了重要的旗舰系列之一。它肩负着重返影像领域顶尖的使命。那么这次P70会带来哪些令人惊艳的创新呢?
根据目前爆料的消息来看,华为P70系列将推出三个版本,其中P70和P70 Pro采用了三角形的摄像头模组设计,而P70 Art则采用了与上一代P60 Art相似的不规则形状设计。这样的外观是否好看见仁见智,但辨识度绝对拉满。