vue+layui模仿微信pc端聊天对话框即时通讯代码

代码语言:html

所属分类:布局界面

代码描述:vue+layui模仿微信pc端聊天对话框即时通讯代码,只要更换一个api接口就能用。

代码标签: vue layui 模仿 微信 pc端 聊天 对话框 即时 通讯 代码

下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开

<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>聊天界面</title>
    <link type="text/css" rel="stylesheet" href="//repo.bfw.wiki/bfwrepo/css/layui.2.9.10.css">
    <script type="text/javascript" src="//repo.bfw.wiki/bfwrepo/js/vue@2.6.1-dev.js"></script>
    <script type="text/javascript" src="//repo.bfw.wiki/bfwrepo/js/axios-0.18.js"></script>
<script type="text/javascript" src="//repo.bfw.wiki/bfwrepo/js/mock.1.0.1.js"></script>
    <style>
        body {
            background-color: #f8f8f8;
        }
        .chat-container {
            display: flex;
            margin: 20px auto;
            max-width: 1200px;
            background-color: #fff;
            border-radius: 10px;
            box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
            overflow: hidden;
        }
        .chat-list {
            width: 300px;
            border-right: 1px solid #e6e6e6;
            background-color: #f9f9f9;
            height: 600px;
            overflow-y: auto;
        }
        .chat-item {
            padding: 12px;
            border-bottom: 1px solid #e6e6e6;
            cursor: pointer;
            display: flex;
            align-items: center;
        }
        .chat-item:hover {
            background-color: #f1f1f1;
        }
        .chat-item-avatar {
            width: 40px;
            height: 40px;
            border-radius: 50%;
            background-color: #ccc;
            margin-right: 10px;
        }
        .chat-item-info {
            flex: 1;
        }
        .chat-item-name {
            font-size: 14px;
            font-weight: bold;
        }
        .chat-item-lastmsg {
            font-size: 12px;
            color: #888;
            margin-top: 4px;
        }
        .chat-window {
            flex: 1;
            display: flex;
            flex-direction: column;
            height: 600px;
        }
        .chat-header {
            padding: 12px;
            border-bottom: 1px solid #e6e6e6;
            font-size: 16px;
            font-weight: bold;
            background-color: #f9f9f9;
        }
        .chat-messages {
            flex: 1;
            padding: 12px;
            overflow-y: auto;
            background-color: #f0f0f0;
        }
        .message {
            margin-bottom: 12px;
            display: flex;
        }
        .message.self {
            justify-content: flex-end;
        }
        .message.other {
            justify-content: flex-start;
        }
        .message-bubble {
            max-width: 70%;
            padding: 8px 12px;
            border-radius: 8px;
            font-size: 14px;
        }
        .message.self .message-bubble {
            background-color: #95ec69;
            color: #000;
        }
        .message.other .message-bubble {
            background-color: #fff;.........完整代码请登录后点击上方下载按钮下载查看

网友评论0