vue+element UI 仿微信at联系人
时间: 2023-11-26 17:03:32 浏览: 108
为了实现Vue+Element UI仿微信at联系人的功能,可以按照以下步骤进行:
1. 首先安装Vue和Element UI,可以使用npm进行安装。
2. 在Vue中使用Element UI的组件,可以在需要使用的组件中引入,例如:
```javascript
import { Input, Autocomplete } from 'element-ui';
export default {
components: {
'el-input': Input,
'el-autocomplete': Autocomplete
}
}
```
3. 在页面中使用Autocomplete组件实现at联系人的功能,例如:
```html
<el-autocomplete
v-model="inputValue"
:fetch-suggestions="querySearchAsync"
placeholder="请输入内容"
@select="handleSelect">
<template slot-scope="{ item }">
<div class="name">{{ item.value }}</div>
</template>
</el-autocomplete>
```
在data中定义inputValue,querySearchAsync方法用于异步获取联系人列表,handleSelect方法用于选择联系人后的回调。
4. 根据微信的UI样式,可以自定义Element UI的样式,例如:
```css
.el-autocomplete .el-input__inner {
padding-left: 30px;
}
.el-autocomplete .el-input__suffix {
font-size: 16px;
color: #999;
left: 10px;
}
.el-autocomplete .el-autocomplete-suggestion__list {
margin-top: 0;
border-radius: 0;
box-shadow: none;
border: 1px solid #dcdfe6;
}
.el-autocomplete .el-autocomplete-suggestion__item {
padding: 10px 20px;
font-size: 14px;
color: #333;
}
.el-autocomplete .el-autocomplete-suggestion__item:hover {
background-color: #f5f7fa;
}
```
5. 最后,根据微信的UI布局,可以使用Element UI的Tabs组件实现左侧联系人列表和右侧消息窗口的切换,例如:
```html
<el-tabs v-model="activeTab">
<el-tab-pane label="联系人列表" name="contact-list">
<!-- 联系人列表 -->
</el-tab-pane>
<el-tab-pane label="消息窗口" name="message-window">
<!-- 消息窗口 -->
</el-tab-pane>
</el-tabs>
```
在data中定义activeTab,用于控制Tabs的切换。
阅读全文
相关推荐
![rar](https://img-home.csdnimg.cn/images/20241231044955.png)
![pdf](https://img-home.csdnimg.cn/images/20241231044930.png)
![pdf](https://img-home.csdnimg.cn/images/20241231044930.png)
![zip](https://img-home.csdnimg.cn/images/20241231045053.png)
![zip](https://img-home.csdnimg.cn/images/20241231045053.png)
![zip](https://img-home.csdnimg.cn/images/20241231045053.png)
![zip](https://img-home.csdnimg.cn/images/20241231045053.png)
![rar](https://img-home.csdnimg.cn/images/20241231044955.png)
![zip](https://img-home.csdnimg.cn/images/20241231045053.png)
![zip](https://img-home.csdnimg.cn/images/20241231045053.png)
![zip](https://img-home.csdnimg.cn/images/20241231045053.png)
![.zip](https://img-home.csdnimg.cn/images/20241231045053.png)
![zip](https://img-home.csdnimg.cn/images/20241231045053.png)
![zip](https://img-home.csdnimg.cn/images/20241231045053.png)
![zip](https://img-home.csdnimg.cn/images/20241231045053.png)
![zip](https://img-home.csdnimg.cn/images/20241231045053.png)
![-](https://img-home.csdnimg.cn/images/20241231045053.png)
![-](https://img-home.csdnimg.cn/images/20241231045053.png)
![-](https://img-home.csdnimg.cn/images/20241231044955.png)