vue.js - 在元素(Vue)自动完成中选择后保持下拉
问题描述
我正在为我的项目使用 Element。当我使用自动完成输入时,我希望在选择元素时保持下拉列表完整,并且仅在模糊时隐藏它。谁能帮我? https://element.eleme.io/#/en-US/component/input
解决方案
如果不分叉库或编写自己的组件,就没有合理的方法可以做到这一点。
Here is the code in elements source that always closes the autocomplete when a choice is selected:
select(item) {
this.$emit('input', item[this.valueKey]);
this.$emit('select', item);
this.$nextTick(_ => {
this.suggestions = []; // This will always close the suggestions tooltip
this.highlightedIndex = -1;
});
}
来源。
如果您不想分叉整个库并且您正在单独导入组件,您可以 1. 导入el-autocomplete
组件,2. 覆盖select
方法,3. 注册修改后的组件。
推荐阅读
- login - 如何使用 Jmeter 登录 LDAP?
- java - 我简单的 Java pi 计算器似乎总是给出无穷大?
- java - 为什么在 ViewModelProvider.Factory 实现中添加 @Singleton 注解会导致编译错误 [Dagger/MissingBinding]?
- javascript - HTTP500:在服务器上使用 ajax POST 但不是 localhost 时出现服务器错误
- c# - 将 X509Certificate2.PrivateKey 解析为 RSACryptoServiceProvider 时出错
- ios - 我可以覆盖prepare for segue 方法以使用UIViewController 扩展添加一些代码吗?
- angular - 如何在 Angular 6 中解决这个问题?
- java - 最大整数值java
- algorithm - 动态规划的加权区间问题
- functional-programming - smlnj - 在 Int 列表中添加偶数和奇数元素的函数